[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
This commit is contained in:
lolimay 2019-05-31 02:56:18 +08:00 committed by Diego Mello
parent 957182bf55
commit a0d0d61458
2 changed files with 9 additions and 3 deletions

View File

@ -58,5 +58,8 @@ export default {
},
Threads_enabled: {
type: null
},
API_Gitlab_URL: {
type: 'valueAsString'
}
};

View File

@ -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();