|
|
@ -24,7 +24,7 @@ func hashAppToken(x *xorm.Engine) error { |
|
|
|
Name string |
|
|
|
Name string |
|
|
|
Sha1 string |
|
|
|
Sha1 string |
|
|
|
Token string `xorm:"-"` |
|
|
|
Token string `xorm:"-"` |
|
|
|
TokenHash string `xorm:"UNIQUE"` // sha256 of token
|
|
|
|
TokenHash string // sha256 of token - we will ensure UNIQUE later
|
|
|
|
TokenSalt string |
|
|
|
TokenSalt string |
|
|
|
TokenLastEight string `xorm:"token_last_eight"` |
|
|
|
TokenLastEight string `xorm:"token_last_eight"` |
|
|
|
|
|
|
|
|
|
|
@ -74,7 +74,7 @@ func hashAppToken(x *xorm.Engine) error { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if err := x.Sync2(new(AccessToken)); err != nil { |
|
|
|
if err := sess.Sync2(new(AccessToken)); err != nil { |
|
|
|
return fmt.Errorf("Sync2: %v", err) |
|
|
|
return fmt.Errorf("Sync2: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -130,6 +130,24 @@ func hashAppToken(x *xorm.Engine) error { |
|
|
|
if err := dropTableColumns(sess, "access_token", "sha1"); err != nil { |
|
|
|
if err := dropTableColumns(sess, "access_token", "sha1"); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
return sess.Commit() |
|
|
|
if err := sess.Commit(); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return resyncHashAppTokenWithUniqueHash(x) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func resyncHashAppTokenWithUniqueHash(x *xorm.Engine) error { |
|
|
|
|
|
|
|
// AccessToken see models/token.go
|
|
|
|
|
|
|
|
type AccessToken struct { |
|
|
|
|
|
|
|
TokenHash string `xorm:"UNIQUE"` // sha256 of token - we will ensure UNIQUE later
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
sess := x.NewSession() |
|
|
|
|
|
|
|
defer sess.Close() |
|
|
|
|
|
|
|
if err := sess.Begin(); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if err := sess.Sync2(new(AccessToken)); err != nil { |
|
|
|
|
|
|
|
return fmt.Errorf("Sync2: %v", err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return sess.Commit() |
|
|
|
} |
|
|
|
} |
|
|
|