Fix oauth routes and link issues
Этот коммит содержится в:
@@ -29,11 +29,14 @@ func InitOAuth(r *mux.Router) {
|
|||||||
sr.Handle("/authorize", ApiUserRequired(authorizeOAuth)).Methods("GET")
|
sr.Handle("/authorize", ApiUserRequired(authorizeOAuth)).Methods("GET")
|
||||||
sr.Handle("/access_token", ApiAppHandler(getAccessToken)).Methods("POST")
|
sr.Handle("/access_token", ApiAppHandler(getAccessToken)).Methods("POST")
|
||||||
|
|
||||||
// Also handle this a the old routes remove soon apiv2?
|
|
||||||
mr := Srv.Router
|
mr := Srv.Router
|
||||||
mr.Handle("/authorize", ApiUserRequired(authorizeOAuth)).Methods("GET")
|
mr.Handle("/authorize", ApiUserRequired(authorizeOAuth)).Methods("GET")
|
||||||
mr.Handle("/access_token", ApiAppHandler(getAccessToken)).Methods("POST")
|
mr.Handle("/access_token", ApiAppHandler(getAccessToken)).Methods("POST")
|
||||||
|
|
||||||
|
// Handle all the old routes, to be later removed
|
||||||
mr.Handle("/{service:[A-Za-z]+}/complete", AppHandlerIndependent(completeOAuth)).Methods("GET")
|
mr.Handle("/{service:[A-Za-z]+}/complete", AppHandlerIndependent(completeOAuth)).Methods("GET")
|
||||||
|
mr.Handle("/signup/{service:[A-Za-z]+}/complete", AppHandlerIndependent(completeOAuth)).Methods("GET")
|
||||||
|
mr.Handle("/login/{service:[A-Za-z]+}/complete", AppHandlerIndependent(completeOAuth)).Methods("GET")
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerOAuthApp(c *Context, w http.ResponseWriter, r *http.Request) {
|
func registerOAuthApp(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -185,7 +188,7 @@ func completeOAuth(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
code := r.URL.Query().Get("code")
|
code := r.URL.Query().Get("code")
|
||||||
state := r.URL.Query().Get("state")
|
state := r.URL.Query().Get("state")
|
||||||
|
|
||||||
uri := c.GetSiteURL() + "/api/v1/oauth/" + service + "/complete"
|
uri := c.GetSiteURL() + "/signup/" + service + "/complete"
|
||||||
|
|
||||||
if body, team, props, err := AuthorizeOAuthUser(service, code, state, uri); err != nil {
|
if body, team, props, err := AuthorizeOAuthUser(service, code, state, uri); err != nil {
|
||||||
c.Err = err
|
c.Err = err
|
||||||
|
|||||||
@@ -1938,7 +1938,7 @@ func GetAuthorizationCode(c *Context, service, teamName string, props map[string
|
|||||||
props["team"] = teamName
|
props["team"] = teamName
|
||||||
state := b64.StdEncoding.EncodeToString([]byte(model.MapToJson(props)))
|
state := b64.StdEncoding.EncodeToString([]byte(model.MapToJson(props)))
|
||||||
|
|
||||||
redirectUri := c.GetSiteURL() + "/api/v1/oauth/" + service + "/complete"
|
redirectUri := c.GetSiteURL() + "/signup/" + service + "/complete"
|
||||||
|
|
||||||
authUrl := endpoint + "?response_type=code&client_id=" + clientId + "&redirect_uri=" + url.QueryEscape(redirectUri) + "&state=" + url.QueryEscape(state)
|
authUrl := endpoint + "?response_type=code&client_id=" + clientId + "&redirect_uri=" + url.QueryEscape(redirectUri) + "&state=" + url.QueryEscape(state)
|
||||||
|
|
||||||
|
|||||||
@@ -60,10 +60,10 @@ export default class Login extends React.Component {
|
|||||||
let loginMessage = [];
|
let loginMessage = [];
|
||||||
if (global.window.mm_config.EnableSignUpWithGitLab === 'true') {
|
if (global.window.mm_config.EnableSignUpWithGitLab === 'true') {
|
||||||
loginMessage.push(
|
loginMessage.push(
|
||||||
<Link
|
<a
|
||||||
className='btn btn-custom-login gitlab'
|
className='btn btn-custom-login gitlab'
|
||||||
key='gitlab'
|
key='gitlab'
|
||||||
to={'/api/v1/oauth/gitlab/login?team=' + encodeURIComponent(teamName)}
|
href={'/api/v1/oauth/gitlab/login?team=' + encodeURIComponent(teamName)}
|
||||||
>
|
>
|
||||||
<span className='icon'/>
|
<span className='icon'/>
|
||||||
<span>
|
<span>
|
||||||
@@ -72,16 +72,16 @@ export default class Login extends React.Component {
|
|||||||
defaultMessage='with GitLab'
|
defaultMessage='with GitLab'
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
</Link>
|
</a>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (global.window.mm_config.EnableSignUpWithGoogle === 'true') {
|
if (global.window.mm_config.EnableSignUpWithGoogle === 'true') {
|
||||||
loginMessage.push(
|
loginMessage.push(
|
||||||
<Link
|
<a
|
||||||
className='btn btn-custom-login google'
|
className='btn btn-custom-login google'
|
||||||
key='google'
|
key='google'
|
||||||
to={'/api/v1/oauth/google/login?team=' + encodeURIComponent(teamName)}
|
href={'/api/v1/oauth/google/login?team=' + encodeURIComponent(teamName)}
|
||||||
>
|
>
|
||||||
<span className='icon'/>
|
<span className='icon'/>
|
||||||
<span>
|
<span>
|
||||||
@@ -90,7 +90,7 @@ export default class Login extends React.Component {
|
|||||||
defaultMessage='with Google Apps'
|
defaultMessage='with Google Apps'
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
</Link>
|
</a>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -317,10 +317,10 @@ class SignupUserComplete extends React.Component {
|
|||||||
var signupMessage = [];
|
var signupMessage = [];
|
||||||
if (global.window.mm_config.EnableSignUpWithGitLab === 'true') {
|
if (global.window.mm_config.EnableSignUpWithGitLab === 'true') {
|
||||||
signupMessage.push(
|
signupMessage.push(
|
||||||
<Link
|
<a
|
||||||
className='btn btn-custom-login gitlab'
|
className='btn btn-custom-login gitlab'
|
||||||
key='gitlab'
|
key='gitlab'
|
||||||
to={'/api/v1/oauth/gitlab/signup' + window.location.search + '&team=' + encodeURIComponent(this.state.teamName)}
|
href={'/api/v1/oauth/gitlab/signup' + window.location.search + '&team=' + encodeURIComponent(this.state.teamName)}
|
||||||
>
|
>
|
||||||
<span className='icon'/>
|
<span className='icon'/>
|
||||||
<span>
|
<span>
|
||||||
@@ -329,16 +329,16 @@ class SignupUserComplete extends React.Component {
|
|||||||
defaultMessage='with GitLab'
|
defaultMessage='with GitLab'
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
</Link>
|
</a>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (global.window.mm_config.EnableSignUpWithGoogle === 'true') {
|
if (global.window.mm_config.EnableSignUpWithGoogle === 'true') {
|
||||||
signupMessage.push(
|
signupMessage.push(
|
||||||
<Link
|
<a
|
||||||
className='btn btn-custom-login google'
|
className='btn btn-custom-login google'
|
||||||
key='google'
|
key='google'
|
||||||
to={'/api/v1/oauth/google/signup' + window.location.search + '&team=' + encodeURIComponent(this.state.teamName)}
|
href={'/api/v1/oauth/google/signup' + window.location.search + '&team=' + encodeURIComponent(this.state.teamName)}
|
||||||
>
|
>
|
||||||
<span className='icon'/>
|
<span className='icon'/>
|
||||||
<span>
|
<span>
|
||||||
@@ -347,7 +347,7 @@ class SignupUserComplete extends React.Component {
|
|||||||
defaultMessage='with Google'
|
defaultMessage='with Google'
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
</Link>
|
</a>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class SSOSignUpPage extends React.Component {
|
|||||||
this.props.service,
|
this.props.service,
|
||||||
(data) => {
|
(data) => {
|
||||||
if (data.follow_link) {
|
if (data.follow_link) {
|
||||||
browserHistory.push(data.follow_link);
|
window.location.href = data.follow_link;
|
||||||
} else {
|
} else {
|
||||||
browserHistory.push('/' + team.name + '/channels/town-square');
|
browserHistory.push('/' + team.name + '/channels/town-square');
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user