Rename to method.

This commit is contained in:
Yang Luo 2021-02-14 15:45:48 +08:00
parent faeb93494c
commit 20b70c323d
5 changed files with 10 additions and 10 deletions

View File

@ -45,7 +45,7 @@ func (c *ApiController) AuthLogin() {
providerName := c.Input().Get("provider") providerName := c.Input().Get("provider")
code := c.Input().Get("code") code := c.Input().Get("code")
state := c.Input().Get("state") state := c.Input().Get("state")
addition := c.Input().Get("addition") method := c.Input().Get("method")
RedirectURL := c.Input().Get("redirect_url") RedirectURL := c.Input().Get("redirect_url")
provider := object.GetProvider(fmt.Sprintf("admin/%s", providerName)) provider := object.GetProvider(fmt.Sprintf("admin/%s", providerName))
@ -131,7 +131,7 @@ func (c *ApiController) AuthLogin() {
}() }()
wg.Wait() wg.Wait()
if addition == "signup" { if method == "signup" {
userId := object.HasGithub(tempUserAccount.Login) userId := object.HasGithub(tempUserAccount.Login)
if userId != "" { if userId != "" {
//if len(object.GetMemberAvatar(userId)) == 0 { //if len(object.GetMemberAvatar(userId)) == 0 {
@ -151,7 +151,7 @@ func (c *ApiController) AuthLogin() {
res.IsSignedUp = false res.IsSignedUp = false
} }
} }
res.Addition = tempUserAccount.Login res.Method = tempUserAccount.Login
res.Avatar = tempUserAccount.AvatarUrl res.Avatar = tempUserAccount.AvatarUrl
resp = Response{Status: "ok", Msg: "success", Data: res} resp = Response{Status: "ok", Msg: "success", Data: res}
} else { } else {

View File

@ -31,5 +31,5 @@ type authResponse struct {
IsSignedUp bool `json:"isSignedUp"` IsSignedUp bool `json:"isSignedUp"`
Email string `json:"email"` Email string `json:"email"`
Avatar string `json:"avatar"` Avatar string `json:"avatar"`
Addition string `json:"addition"` Method string `json:"method"`
} }

View File

@ -274,7 +274,7 @@ class App extends Component {
</Header> </Header>
<Switch> <Switch>
<Route exact path="/login" render={(props) => this.renderHomeIfLoggedIn(<LoginPage onLoggedIn={this.onLoggedIn.bind(this)} {...props} />)}/> <Route exact path="/login" render={(props) => this.renderHomeIfLoggedIn(<LoginPage onLoggedIn={this.onLoggedIn.bind(this)} {...props} />)}/>
<Route exact path="/callback/:providerType/:providerName/:addition" component={AuthCallback}/> <Route exact path="/callback/:providerType/:providerName/:method" component={AuthCallback}/>
<Route exact path="/" render={(props) => this.renderLoginIfNotLoggedIn(<HomePage account={this.state.account} onLoggedIn={this.onLoggedIn.bind(this)} {...props} />)}/> <Route exact path="/" render={(props) => this.renderLoginIfNotLoggedIn(<HomePage account={this.state.account} onLoggedIn={this.onLoggedIn.bind(this)} {...props} />)}/>
<Route exact path="/account" render={(props) => this.renderLoginIfNotLoggedIn(<AccountPage account={this.state.account} {...props} />)}/> <Route exact path="/account" render={(props) => this.renderLoginIfNotLoggedIn(<AccountPage account={this.state.account} {...props} />)}/>
<Route exact path="/organizations" render={(props) => this.renderLoginIfNotLoggedIn(<OrganizationListPage account={this.state.account} {...props} />)}/> <Route exact path="/organizations" render={(props) => this.renderLoginIfNotLoggedIn(<OrganizationListPage account={this.state.account} {...props} />)}/>

View File

@ -44,8 +44,8 @@ export function logout() {
}).then(res => res.json()); }).then(res => res.json());
} }
export function authLogin(providerName, code, state, redirectUrl, 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}&addition=${addition}`, { return fetch(`${Setting.ServerUrl}/api/auth/login?provider=${providerName}&code=${code}&state=${state}&redirect_url=${redirectUrl}&method=${method}`, {
method: 'GET', method: 'GET',
credentials: 'include', credentials: 'include',
}).then(res => res.json()); }).then(res => res.json());

View File

@ -26,7 +26,7 @@ class AuthCallback extends React.Component {
classes: props, classes: props,
providerType: props.match.params.providerType, providerType: props.match.params.providerType,
providerName: props.match.params.providerName, providerName: props.match.params.providerName,
addition: props.match.params.addition, method: props.match.params.method,
state: params.get("state"), state: params.get("state"),
code: params.get("code"), code: params.get("code"),
isAuthenticated: false, isAuthenticated: false,
@ -49,8 +49,8 @@ class AuthCallback extends React.Component {
authLogin() { authLogin() {
let redirectUrl; let redirectUrl;
redirectUrl = `${getClientUrl()}/callback/${this.state.providerType}/${this.state.providerName}/${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.addition) AuthBackend.authLogin(this.state.providerName, this.state.code, this.state.state, redirectUrl, this.state.method)
.then((res) => { .then((res) => {
if (res.status === "ok") { if (res.status === "ok") {
window.location.href = '/'; window.location.href = '/';