-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidator.go
More file actions
44 lines (38 loc) · 917 Bytes
/
validator.go
File metadata and controls
44 lines (38 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package UsersBackend
import (
"fmt"
pasproj "github.com/HRMonitorr/PasetoprojectBackend"
"math/rand"
)
func IsAdmin(Tokenstr, PublicKey string) bool {
role, err := pasproj.DecodeGetRole(PublicKey, Tokenstr)
if err != nil {
fmt.Println("Error : " + err.Error())
}
if role != "admin" {
return false
}
return true
}
func IsHR(TokenStr, Publickey string) bool {
role, err := pasproj.DecodeGetRole(Publickey, TokenStr)
if err != nil {
fmt.Println("Error : " + err.Error())
}
if role != "HR" {
return false
}
return true
}
func CreateOTP() string {
return RandStringBytes(6)
}
// generateRandomString generates a random string of a specified length using the given characters.
const letterBytes = "ABCDEFGHIJKLMNOPQRSTUVWXZ1238849103748102"
func RandStringBytes(n int) string {
b := make([]byte, n)
for i := range b {
b[i] = letterBytes[rand.Intn(len(letterBytes))]
}
return string(b)
}