mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 12:30:19 +08:00
Improve router base.go
This commit is contained in:
@ -62,3 +62,22 @@ func getUsernameByClientIdSecret(ctx *context.Context) string {
|
||||
|
||||
return fmt.Sprintf("app/%s", application.Name)
|
||||
}
|
||||
|
||||
func getSessionUser(ctx *context.Context) string {
|
||||
user := ctx.Input.CruSession.Get("username")
|
||||
if user == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
return user.(string)
|
||||
}
|
||||
|
||||
func setSessionUser(ctx *context.Context, user string) {
|
||||
err := ctx.Input.CruSession.Set("username", user)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// https://github.com/beego/beego/issues/3445#issuecomment-455411915
|
||||
ctx.Input.CruSession.SessionRelease(ctx.ResponseWriter)
|
||||
}
|
||||
|
Reference in New Issue
Block a user