(ctx context.Context, userID bson.ObjectID)
| 34 | } |
| 35 | |
| 36 | func (s *TokenService) CreateRefreshToken(ctx context.Context, userID bson.ObjectID) (*Token, error) { |
| 37 | token := &Token{ |
| 38 | ID: bson.NewObjectID(), |
| 39 | UserID: userID, |
| 40 | Type: "refreshToken", |
| 41 | Token: bson.NewObjectID().Hex(), |
| 42 | ExpiresAt: time.Now().Add(time.Hour * 24 * 30), |
| 43 | } |
| 44 | _, err := s.tokenCollection.InsertOne(ctx, token) |
| 45 | return token, err |
| 46 | } |
| 47 | |
| 48 | func (s *TokenService) GetTokenByToken(ctx context.Context, token string) (*Token, error) { |
| 49 | var tokenObj Token |
no outgoing calls