From a0d0d61458514069dc02b692fbdc7b92ccd2dea8 Mon Sep 17 00:00:00 2001 From: lolimay Date: Fri, 31 May 2019 02:56:18 +0800 Subject: [PATCH] [FIX] Gitlab url hardcoded (#921) * [FIX] Gitlab url hardcoded problem * Closes https://github.com/RocketChat/Rocket.Chat.ReactNative/issues/251 * Fix API_Gitlab_URL type --- app/constants/settings.js | 3 +++ app/views/LoginSignupView.js | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/constants/settings.js b/app/constants/settings.js index 78b229522..8e8e9b8c8 100644 --- a/app/constants/settings.js +++ b/app/constants/settings.js @@ -58,5 +58,8 @@ export default { }, Threads_enabled: { type: null + }, + API_Gitlab_URL: { + type: 'valueAsString' } }; diff --git a/app/views/LoginSignupView.js b/app/views/LoginSignupView.js index a80d8b50b..1b09b994f 100644 --- a/app/views/LoginSignupView.js +++ b/app/views/LoginSignupView.js @@ -91,6 +91,7 @@ const SERVICES_COLLAPSED_HEIGHT = 174; @connect(state => ({ server: state.server.server, Site_Name: state.settings.Site_Name, + Gitlab_URL: state.settings.API_Gitlab_URL, services: state.login.services })) export default class LoginSignupView extends React.Component { @@ -106,7 +107,8 @@ export default class LoginSignupView extends React.Component { navigation: PropTypes.object, server: PropTypes.string, services: PropTypes.object, - Site_Name: PropTypes.string + Site_Name: PropTypes.string, + Gitlab_URL: PropTypes.string } constructor(props) { @@ -175,9 +177,10 @@ export default class LoginSignupView extends React.Component { } onPressGitlab = () => { - const { services, server } = this.props; + const { services, server, Gitlab_URL } = this.props; const { clientId } = services.gitlab; - const endpoint = 'https://gitlab.com/oauth/authorize'; + const baseURL = Gitlab_URL ? Gitlab_URL.trim().replace(/\/*$/, '') : 'https://gitlab.com'; + const endpoint = `${ baseURL }/oauth/authorize`; const redirect_uri = `${ server }/_oauth/gitlab?close`; const scope = 'read_user'; const state = this.getOAuthState();