(uuid string, did string, pds string, accessToken string, refreshToken string, encryptionKey string, accessExpiry float64, refreshExpiry float64, tokenVersion int)
| 168 | } |
| 169 | |
| 170 | func UpdateToken(uuid string, did string, pds string, accessToken string, refreshToken string, encryptionKey string, accessExpiry float64, refreshExpiry float64, tokenVersion int) (*string, error) { |
| 171 | encryptedAccess, err := authcrypt.Encrypt(accessToken, encryptionKey) |
| 172 | if err != nil { |
| 173 | return nil, fmt.Errorf("failed to encrypt access token: %v", err) |
| 174 | } |
| 175 | |
| 176 | encryptedRefresh, err := authcrypt.Encrypt(refreshToken, encryptionKey) |
| 177 | if err != nil { |
| 178 | return nil, fmt.Errorf("failed to encrypt refresh token: %v", err) |
| 179 | } |
| 180 | |
| 181 | token := Token{ |
| 182 | UserDid: did, |
| 183 | TokenUUID: uuid, |
| 184 | UserPDS: pds, |
| 185 | EncryptedAccessToken: encryptedAccess, |
| 186 | EncryptedRefreshToken: encryptedRefresh, |
| 187 | AccessExpiry: accessExpiry, |
| 188 | RefreshExpiry: refreshExpiry, |
| 189 | TokenVersion: tokenVersion, |
| 190 | } |
| 191 | |
| 192 | result := db.Clauses(clause.OnConflict{ |
| 193 | Columns: []clause.Column{ |
| 194 | {Name: "user_did"}, |
| 195 | {Name: "token_uuid"}, |
| 196 | }, |
| 197 | UpdateAll: true, |
| 198 | }).Create(&token) |
| 199 | |
| 200 | if result.Error != nil { |
| 201 | return nil, result.Error |
| 202 | } |
| 203 | |
| 204 | return &token.TokenUUID, nil |
| 205 | } |
| 206 | |
| 207 | // StoreTokenBasic stores a token using basic auth (password) |
| 208 | func StoreTokenBasic(did string, pds string, accessToken string, refreshToken string, username string, password string, accessExpiry float64, refreshExpiry float64) (*string, error) { |
no outgoing calls
no test coverage detected