mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 12:30:19 +08:00
feat: add access key and secret key for user (#1971)
This commit is contained in:
@ -84,6 +84,18 @@ func getUsernameByClientIdSecret(ctx *context.Context) string {
|
||||
return fmt.Sprintf("app/%s", application.Name)
|
||||
}
|
||||
|
||||
func getUsernameByKeys(ctx *context.Context) string {
|
||||
accessKey, secretKey := getKeys(ctx)
|
||||
user, err := object.GetUserByAccessKey(accessKey)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if user != nil && secretKey == user.SecretKey {
|
||||
return user.GetId()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func getSessionUser(ctx *context.Context) string {
|
||||
user := ctx.Input.CruSession.Get("username")
|
||||
if user == nil {
|
||||
|
Reference in New Issue
Block a user