ent seteup
This commit is contained in:
9
pkg/auth/auth.go
Normal file
9
pkg/auth/auth.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package auth
|
||||
|
||||
import "gitserver.in/patialtech/rano/graph/model"
|
||||
|
||||
type AuthUser = model.AuthUser
|
||||
|
||||
func authenticate(email, pwd string) (*AuthUser, error) {
|
||||
panic("not implemented")
|
||||
}
|
28
pkg/auth/ctx.go
Normal file
28
pkg/auth/ctx.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitserver.in/patialtech/rano/config"
|
||||
)
|
||||
|
||||
type SessionUser struct {
|
||||
ID int64
|
||||
Email string
|
||||
DisplayName string
|
||||
RoleID int
|
||||
}
|
||||
|
||||
func CtxWithUser(ctx context.Context, u *AuthUser) context.Context {
|
||||
return context.WithValue(ctx, config.AuthUserCtxKey, &SessionUser{
|
||||
ID: u.ID,
|
||||
Email: u.Email,
|
||||
DisplayName: u.DisplayName,
|
||||
RoleID: u.RoleID,
|
||||
})
|
||||
}
|
||||
|
||||
func CtxUser(ctx context.Context) *SessionUser {
|
||||
u, _ := ctx.Value(config.AuthUserCtxKey).(*SessionUser)
|
||||
return u
|
||||
}
|
13
pkg/auth/password.go
Normal file
13
pkg/auth/password.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package auth
|
||||
|
||||
// EmailResetPWD link to user to reset password
|
||||
func EmailResetPWD(email string) {
|
||||
// send Password reset instructionss
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
// UpdatePWD in database
|
||||
func UpdatePWD(token, email, pwd, confirmPWD string) error {
|
||||
// update pwd in DB
|
||||
panic("not implemented")
|
||||
}
|
17
pkg/auth/session.go
Normal file
17
pkg/auth/session.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package auth
|
||||
|
||||
// NewSession for user.
|
||||
//
|
||||
// Authenticated
|
||||
func NewSession(email, pwd string) (*AuthUser, error) {
|
||||
// authenticate.
|
||||
|
||||
// create sesion entry in db
|
||||
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
// RemoveSession entry from DB
|
||||
func RemoveSession(sID uint) {
|
||||
panic("not implemented")
|
||||
}
|
Reference in New Issue
Block a user