fix: extract html rendering
This commit was merged in pull request #291.
This commit is contained in:
@@ -9,12 +9,10 @@ import (
|
||||
"time"
|
||||
|
||||
"me-fit/db"
|
||||
"me-fit/template/auth"
|
||||
mailTemplate "me-fit/template/mail"
|
||||
"me-fit/types"
|
||||
"me-fit/utils"
|
||||
|
||||
"github.com/a-h/templ"
|
||||
"github.com/google/uuid"
|
||||
"golang.org/x/crypto/argon2"
|
||||
)
|
||||
@@ -56,15 +54,19 @@ func NewSession(session *db.Session, user *User) *Session {
|
||||
}
|
||||
|
||||
type AuthService interface {
|
||||
SignIn(email string, password string) (*Session, error)
|
||||
SignUp(email string, password string) (*User, error)
|
||||
SendVerificationMail(userId uuid.UUID, email string)
|
||||
VerifyUserEmail(token string) error
|
||||
|
||||
SignIn(email string, password string) (*Session, error)
|
||||
SignOut(sessionId string) error
|
||||
|
||||
DeleteAccount(user *User) error
|
||||
|
||||
ChangePassword(user *User, currPass, newPass string) error
|
||||
ForgotPassword(email string) error
|
||||
ForgotPasswordResponse(token string, newPass string) error
|
||||
|
||||
SendForgotPasswordMail(email string) error
|
||||
ForgotPassword(token string, newPass string) error
|
||||
|
||||
GetUserFromSessionId(sessionId string) (*User, error)
|
||||
}
|
||||
@@ -271,17 +273,6 @@ func (service AuthServiceImpl) GetUserFromSessionId(sessionId string) (*User, er
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
||||
func UserInfoComp(user *User) templ.Component {
|
||||
|
||||
if user != nil {
|
||||
return auth.UserComp(user.Email)
|
||||
} else {
|
||||
return auth.UserComp("")
|
||||
}
|
||||
}
|
||||
|
||||
func (service AuthServiceImpl) DeleteAccount(user *User) error {
|
||||
|
||||
err := service.dbAuth.DeleteUser(user.Id)
|
||||
@@ -326,7 +317,7 @@ func (service AuthServiceImpl) ChangePassword(user *User, currPass, newPass stri
|
||||
return nil
|
||||
}
|
||||
|
||||
func (service AuthServiceImpl) ForgotPassword(email string) error {
|
||||
func (service AuthServiceImpl) SendForgotPasswordMail(email string) error {
|
||||
|
||||
tokenStr, err := service.randomGenerator.String(32)
|
||||
if err != nil {
|
||||
@@ -360,7 +351,7 @@ func (service AuthServiceImpl) ForgotPassword(email string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (service AuthServiceImpl) ForgotPasswordResponse(tokenStr string, newPass string) error {
|
||||
func (service AuthServiceImpl) ForgotPassword(tokenStr string, newPass string) error {
|
||||
|
||||
if !isPasswordValid(newPass) {
|
||||
return ErrInvalidPassword
|
||||
|
||||
Reference in New Issue
Block a user