35 lines
1.0 KiB
Go
35 lines
1.0 KiB
Go
![]() |
package provider_template
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"time"
|
||
|
|
||
|
"github.com/google/uuid"
|
||
|
|
||
|
"github.com/authorizerdev/authorizer/server/db/models"
|
||
|
)
|
||
|
|
||
|
func (p *provider) AddAuthenticator(ctx context.Context, authenticators *models.Authenticator) (*models.Authenticator, error) {
|
||
|
exists, _ := p.GetAuthenticatorDetailsByUserId(ctx, authenticators.UserID, authenticators.Method)
|
||
|
if exists != nil {
|
||
|
return authenticators, nil
|
||
|
}
|
||
|
|
||
|
if authenticators.ID == "" {
|
||
|
authenticators.ID = uuid.New().String()
|
||
|
}
|
||
|
authenticators.CreatedAt = time.Now().Unix()
|
||
|
authenticators.UpdatedAt = time.Now().Unix()
|
||
|
return authenticators, nil
|
||
|
}
|
||
|
|
||
|
func (p *provider) UpdateAuthenticator(ctx context.Context, authenticators *models.Authenticator) (*models.Authenticator, error) {
|
||
|
authenticators.UpdatedAt = time.Now().Unix()
|
||
|
return authenticators, nil
|
||
|
}
|
||
|
|
||
|
func (p *provider) GetAuthenticatorDetailsByUserId(ctx context.Context, userId string, authenticatorType string) (*models.Authenticator, error) {
|
||
|
var authenticators *models.Authenticator
|
||
|
return authenticators, nil
|
||
|
}
|