feat:
* encrypted userid * added totp_verified column in user table * started test for totp
This commit is contained in:
@@ -3,8 +3,6 @@ package sql
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"crypto/rsa"
|
||||
"fmt"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"image/png"
|
||||
@@ -60,18 +58,14 @@ func (p *provider) ValidatePasscode(ctx context.Context, passcode string, id str
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("error while getting user details")
|
||||
}
|
||||
|
||||
// validate passcode inputted by user
|
||||
|
||||
status := totp.Validate(passcode, *user.TotpSecret)
|
||||
if !user.TotpVerified {
|
||||
if status {
|
||||
user.TotpVerified = true
|
||||
p.UpdateUser(ctx, user)
|
||||
return status, nil
|
||||
}
|
||||
return status, nil
|
||||
}
|
||||
return status, nil
|
||||
}
|
||||
|
||||
func (p *provider) GenerateKeysTOTP() (*rsa.PublicKey, error) {
|
||||
privateKey, err := rsa.GenerateKey(rand.Reader, 1024)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
publicKey := privateKey.PublicKey
|
||||
return &publicKey, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user