WIP: Enrollement MFA avec TOTP
This commit is contained in:
parent
274a30480e
commit
53c94a490c
10 changed files with 144 additions and 1 deletions
|
|
@ -2,9 +2,11 @@ package helpers
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.readonly.ch/bouzoure/popvaud-people/models"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
|
|
@ -73,3 +75,23 @@ func UserExistsAndIsActive(id uint) (bool, error) {
|
|||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func GetSessionUserId(c *fiber.Ctx) (uint, error) {
|
||||
sess, err := GetSessionStore(c)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
userid := sess.Get("userid")
|
||||
if userid == nil {
|
||||
return 0, fmt.Errorf("no value for key userid in session")
|
||||
}
|
||||
|
||||
switch userid.(type) {
|
||||
case uint:
|
||||
default:
|
||||
return 0, fmt.Errorf("userid value is not of type uint as expected")
|
||||
}
|
||||
|
||||
return userid.(uint), nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue