mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-02 19:40:19 +08:00
feat: add token to the page for Chrome extension (#2804)
* feat: add token to the page for Chrome extension * Update token_oauth.go --------- Co-authored-by: Eric Luo <hsluoyz@qq.com>
This commit is contained in:
@ -45,6 +45,7 @@ func InitDb() {
|
||||
}
|
||||
|
||||
initWebAuthn()
|
||||
initToken()
|
||||
}
|
||||
|
||||
func getBuiltInAccountItems() []*AccountItem {
|
||||
@ -309,6 +310,10 @@ func initWebAuthn() {
|
||||
gob.Register(webauthn.SessionData{})
|
||||
}
|
||||
|
||||
func initToken() {
|
||||
gob.Register(&Token{})
|
||||
}
|
||||
|
||||
func initBuiltInUserModel() {
|
||||
model, err := GetModel("built-in/user-model-built-in")
|
||||
if err != nil {
|
||||
|
@ -726,3 +726,19 @@ func GetWechatMiniProgramToken(application *Application, code string, host strin
|
||||
}
|
||||
return token, nil, nil
|
||||
}
|
||||
|
||||
func GetTokenForExtension(user *User, host string) (*Token, error) {
|
||||
application, err := GetApplicationByUser(user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if application == nil {
|
||||
return nil, fmt.Errorf("the application for user %s is not found", user.Id)
|
||||
}
|
||||
|
||||
token, err := GetTokenByUser(application, user, "profile", "", host)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return token, nil
|
||||
}
|
||||
|
@ -98,6 +98,7 @@ type User struct {
|
||||
PreHash string `xorm:"varchar(100)" json:"preHash"`
|
||||
AccessKey string `xorm:"varchar(100)" json:"accessKey"`
|
||||
AccessSecret string `xorm:"varchar(100)" json:"accessSecret"`
|
||||
AccessToken string `xorm:"mediumtext" json:"accessToken"`
|
||||
|
||||
CreatedIp string `xorm:"varchar(100)" json:"createdIp"`
|
||||
LastSigninTime string `xorm:"varchar(100)" json:"lastSigninTime"`
|
||||
|
Reference in New Issue
Block a user