GetToken retrieves account data from the database @results: accessToken, refreshToken, accessExpiry, refreshExpiry, pds, error
(did string, tokenUUID string, encryptionKey string, tokenVersion int)
| 257 | // @results: accessToken, refreshToken, accessExpiry, refreshExpiry, pds, error |
| 258 | |
| 259 | func GetToken(did string, tokenUUID string, encryptionKey string, tokenVersion int) (*string, *string, *float64, *float64, *string, error) { |
| 260 | var token Token |
| 261 | if err := db.Where("user_did = ? AND token_uuid = ? AND token_version = ?", did, tokenUUID, tokenVersion).First(&token).Error; err != nil { |
| 262 | return nil, nil, nil, nil, nil, err |
| 263 | } |
| 264 | |
| 265 | accessToken, err := authcrypt.Decrypt(token.EncryptedAccessToken, encryptionKey) |
| 266 | if err != nil { |
| 267 | return nil, nil, nil, nil, nil, err |
| 268 | } |
| 269 | |
| 270 | refreshToken, err := authcrypt.Decrypt(token.EncryptedRefreshToken, encryptionKey) |
| 271 | if err != nil { |
| 272 | return nil, nil, nil, nil, nil, err |
| 273 | } |
| 274 | |
| 275 | return &accessToken, &refreshToken, &token.AccessExpiry, &token.RefreshExpiry, &token.UserPDS, nil |
| 276 | } |
| 277 | |
| 278 | // GetTokenViaBasic retrieves a token using only the password |
| 279 | // @results: accessToken, refreshToken, accessExpiry, refreshExpiry, pds, did, hash, salt, uuid, error |