feat: login wall (#42)

* feat: add login-wall app

* fix: rename vars

* fix: rename vars

* update docker file

* add validations for app state

* add host check for app

* fix: docker file
This commit is contained in:
Lakhan Samani
2021-08-04 12:18:57 +05:30
committed by GitHub
parent d1973c1f8f
commit f88363e6dc
41 changed files with 2274 additions and 120 deletions

View File

@@ -9,6 +9,7 @@ import (
type UserInfo struct {
Email string `json:"email"`
Host string `json:"host"`
}
type CustomClaim struct {
@@ -18,7 +19,7 @@ type CustomClaim struct {
}
// TODO convert tokenType to enum
func CreateVerificationToken(email string, tokenType string) (string, error) {
func CreateVerificationToken(email string, tokenType string, host string) (string, error) {
t := jwt.New(jwt.GetSigningMethod(constants.JWT_TYPE))
t.Claims = &CustomClaim{
@@ -27,7 +28,7 @@ func CreateVerificationToken(email string, tokenType string) (string, error) {
ExpiresAt: time.Now().Add(time.Minute * 30).Unix(),
},
tokenType,
UserInfo{Email: email},
UserInfo{Email: email, Host: host},
}
return t.SignedString([]byte(constants.JWT_SECRET))