diff --git a/controllers/auth.go b/controllers/auth.go index 14841024..4b067a2d 100644 --- a/controllers/auth.go +++ b/controllers/auth.go @@ -45,7 +45,7 @@ func (c *ApiController) AuthLogin() { providerName := c.Input().Get("provider") code := c.Input().Get("code") state := c.Input().Get("state") - addition := c.Input().Get("addition") + method := c.Input().Get("method") RedirectURL := c.Input().Get("redirect_url") provider := object.GetProvider(fmt.Sprintf("admin/%s", providerName)) @@ -131,7 +131,7 @@ func (c *ApiController) AuthLogin() { }() wg.Wait() - if addition == "signup" { + if method == "signup" { userId := object.HasGithub(tempUserAccount.Login) if userId != "" { //if len(object.GetMemberAvatar(userId)) == 0 { @@ -151,7 +151,7 @@ func (c *ApiController) AuthLogin() { res.IsSignedUp = false } } - res.Addition = tempUserAccount.Login + res.Method = tempUserAccount.Login res.Avatar = tempUserAccount.AvatarUrl resp = Response{Status: "ok", Msg: "success", Data: res} } else { diff --git a/controllers/type.go b/controllers/type.go index 8059a840..7842baee 100644 --- a/controllers/type.go +++ b/controllers/type.go @@ -31,5 +31,5 @@ type authResponse struct { IsSignedUp bool `json:"isSignedUp"` Email string `json:"email"` Avatar string `json:"avatar"` - Addition string `json:"addition"` + Method string `json:"method"` } diff --git a/web/src/App.js b/web/src/App.js index 9c3ebf0b..a445bebe 100644 --- a/web/src/App.js +++ b/web/src/App.js @@ -274,7 +274,7 @@ class App extends Component { this.renderHomeIfLoggedIn()}/> - + this.renderLoginIfNotLoggedIn()}/> this.renderLoginIfNotLoggedIn()}/> this.renderLoginIfNotLoggedIn()}/> diff --git a/web/src/auth/AuthBackend.js b/web/src/auth/AuthBackend.js index 65aa4f8d..f96d2e13 100644 --- a/web/src/auth/AuthBackend.js +++ b/web/src/auth/AuthBackend.js @@ -44,8 +44,8 @@ export function logout() { }).then(res => res.json()); } -export function authLogin(providerName, code, state, redirectUrl, addition) { - return fetch(`${Setting.ServerUrl}/api/auth/login?provider=${providerName}&code=${code}&state=${state}&redirect_url=${redirectUrl}&addition=${addition}`, { +export function authLogin(providerName, code, state, redirectUrl, method) { + return fetch(`${Setting.ServerUrl}/api/auth/login?provider=${providerName}&code=${code}&state=${state}&redirect_url=${redirectUrl}&method=${method}`, { method: 'GET', credentials: 'include', }).then(res => res.json()); diff --git a/web/src/auth/AuthCallback.js b/web/src/auth/AuthCallback.js index 793f85d7..4ce68ec6 100644 --- a/web/src/auth/AuthCallback.js +++ b/web/src/auth/AuthCallback.js @@ -26,7 +26,7 @@ class AuthCallback extends React.Component { classes: props, providerType: props.match.params.providerType, providerName: props.match.params.providerName, - addition: props.match.params.addition, + method: props.match.params.method, state: params.get("state"), code: params.get("code"), isAuthenticated: false, @@ -49,8 +49,8 @@ class AuthCallback extends React.Component { authLogin() { let redirectUrl; - redirectUrl = `${getClientUrl()}/callback/${this.state.providerType}/${this.state.providerName}/${this.state.addition}`; - AuthBackend.authLogin(this.state.providerName, this.state.code, this.state.state, redirectUrl, this.state.addition) + redirectUrl = `${getClientUrl()}/callback/${this.state.providerType}/${this.state.providerName}/${this.state.method}`; + AuthBackend.authLogin(this.state.providerName, this.state.code, this.state.state, redirectUrl, this.state.method) .then((res) => { if (res.status === "ok") { window.location.href = '/';