File tree 1 file changed +21
-3
lines changed
1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ func hashAppToken(x *xorm.Engine) error {
24
24
Name string
25
25
Sha1 string
26
26
Token string `xorm:"-"`
27
- TokenHash string `xorm:"UNIQUE"` // sha256 of token
27
+ TokenHash string // sha256 of token - we will ensure UNIQUE later
28
28
TokenSalt string
29
29
TokenLastEight string `xorm:"token_last_eight"`
30
30
@@ -74,7 +74,7 @@ func hashAppToken(x *xorm.Engine) error {
74
74
return err
75
75
}
76
76
77
- if err := x .Sync2 (new (AccessToken )); err != nil {
77
+ if err := sess .Sync2 (new (AccessToken )); err != nil {
78
78
return fmt .Errorf ("Sync2: %v" , err )
79
79
}
80
80
@@ -130,6 +130,24 @@ func hashAppToken(x *xorm.Engine) error {
130
130
if err := dropTableColumns (sess , "access_token" , "sha1" ); err != nil {
131
131
return err
132
132
}
133
- return sess .Commit ()
133
+ if err := sess .Commit (); err != nil {
134
+ return err
135
+ }
136
+ return resyncHashAppTokenWithUniqueHash (x )
137
+ }
134
138
139
+ func resyncHashAppTokenWithUniqueHash (x * xorm.Engine ) error {
140
+ // AccessToken see models/token.go
141
+ type AccessToken struct {
142
+ TokenHash string `xorm:"UNIQUE"` // sha256 of token - we will ensure UNIQUE later
143
+ }
144
+ sess := x .NewSession ()
145
+ defer sess .Close ()
146
+ if err := sess .Begin (); err != nil {
147
+ return err
148
+ }
149
+ if err := sess .Sync2 (new (AccessToken )); err != nil {
150
+ return fmt .Errorf ("Sync2: %v" , err )
151
+ }
152
+ return sess .Commit ()
135
153
}
You can’t perform that action at this time.
0 commit comments