mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-02 11:20:18 +08:00
Fix double GET params issue, fix double state bug.
This commit is contained in:
@ -113,8 +113,9 @@ func (c *ApiController) Login() {
|
|||||||
|
|
||||||
var res authResponse
|
var res authResponse
|
||||||
|
|
||||||
if form.State != beego.AppConfig.String("AuthState") {
|
if form.State != beego.AppConfig.String("AuthState") && form.State != application.Name {
|
||||||
resp = &Response{Status: "error", Msg: "unauthorized", Data: res}
|
resp = &Response{Status: "error", Msg: fmt.Sprintf("state expected: \"%s\", but got: \"%s\"", beego.AppConfig.String("AuthState"), form.State), Data: res}
|
||||||
|
c.Data["json"] = resp
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -127,7 +128,7 @@ func (c *ApiController) Login() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !token.Valid() {
|
if !token.Valid() {
|
||||||
resp = &Response{Status: "error", Msg: "unauthorized", Data: res}
|
resp = &Response{Status: "error", Msg: "invalid token", Data: res}
|
||||||
c.Data["json"] = resp
|
c.Data["json"] = resp
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
return
|
return
|
||||||
@ -135,7 +136,7 @@ func (c *ApiController) Login() {
|
|||||||
|
|
||||||
res.Email, res.Method, res.Avatar, err = idProvider.GetUserInfo(httpClient, token)
|
res.Email, res.Method, res.Avatar, err = idProvider.GetUserInfo(httpClient, token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
resp = &Response{Status: "error", Msg: "Login failed, please try again."}
|
resp = &Response{Status: "error", Msg: "login failed, please try again."}
|
||||||
c.Data["json"] = resp
|
c.Data["json"] = resp
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
return
|
return
|
||||||
|
@ -31,8 +31,7 @@ class AuthCallback extends React.Component {
|
|||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
const params = new URLSearchParams(this.props.location.search);
|
const params = new URLSearchParams(this.props.location.search);
|
||||||
let redirectUri;
|
let redirectUri = `${window.location.origin}/callback/${this.state.applicationName}/${this.state.providerName}/${this.state.method}`;
|
||||||
redirectUri = `${window.location.origin}/callback/${this.state.applicationName}/${this.state.providerName}/${this.state.method}`;
|
|
||||||
const body = {
|
const body = {
|
||||||
application: this.state.applicationName,
|
application: this.state.applicationName,
|
||||||
provider: this.state.providerName,
|
provider: this.state.providerName,
|
||||||
|
@ -43,7 +43,7 @@ export function getAuthLogo(provider) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getAuthUrl(application, provider, method) {
|
export function getAuthUrl(application, provider, method) {
|
||||||
const redirectUri = `${window.location.origin}/callback/${application.name}/${provider.name}/${method}`;
|
const redirectUri = `${window.location.origin}/callback/${application.name}/${provider.name}/${method}${encodeURIComponent(window.location.search)}`;
|
||||||
if (provider.type === "google") {
|
if (provider.type === "google") {
|
||||||
return `${GoogleAuthUri}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${GoogleAuthScope}&response_type=code&state=${AuthState}`;
|
return `${GoogleAuthUri}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${GoogleAuthScope}&response_type=code&state=${AuthState}`;
|
||||||
} else if (provider.type === "github") {
|
} else if (provider.type === "github") {
|
||||||
|
Reference in New Issue
Block a user