refactor: modify CreateAccount to optionally send an email verification
This commit is contained in:
parent
8965395fdf
commit
90834601d7
|
@ -82,7 +82,7 @@ func (s *AccountServiceDefault) HashPassword(password string) (string, error) {
|
||||||
return string(bytes), nil
|
return string(bytes), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *AccountServiceDefault) CreateAccount(email string, password string) (*models.User, error) {
|
func (s *AccountServiceDefault) CreateAccount(email string, password string, verifyEmail bool) (*models.User, error) {
|
||||||
passwordHash, err := s.HashPassword(password)
|
passwordHash, err := s.HashPassword(password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -98,6 +98,13 @@ func (s *AccountServiceDefault) CreateAccount(email string, password string) (*m
|
||||||
return nil, NewAccountError(ErrKeyAccountCreationFailed, result.Error)
|
return nil, NewAccountError(ErrKeyAccountCreationFailed, result.Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if verifyEmail {
|
||||||
|
err = s.SendEmailVerification(&user)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return &user, nil
|
return &user, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
api/s5/s5.go
14
api/s5/s5.go
|
@ -10,11 +10,6 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.lumeweb.com/LumeWeb/portal/api/router"
|
|
||||||
"git.lumeweb.com/LumeWeb/portal/bao"
|
|
||||||
"git.lumeweb.com/LumeWeb/portal/renter"
|
|
||||||
"github.com/aws/aws-sdk-go-v2/aws"
|
|
||||||
"github.com/aws/aws-sdk-go-v2/service/s3"
|
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
|
@ -24,6 +19,12 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.lumeweb.com/LumeWeb/portal/api/router"
|
||||||
|
"git.lumeweb.com/LumeWeb/portal/bao"
|
||||||
|
"git.lumeweb.com/LumeWeb/portal/renter"
|
||||||
|
"github.com/aws/aws-sdk-go-v2/aws"
|
||||||
|
"github.com/aws/aws-sdk-go-v2/service/s3"
|
||||||
|
|
||||||
"git.lumeweb.com/LumeWeb/portal/cron"
|
"git.lumeweb.com/LumeWeb/portal/cron"
|
||||||
|
|
||||||
"git.lumeweb.com/LumeWeb/portal/config"
|
"git.lumeweb.com/LumeWeb/portal/config"
|
||||||
|
@ -57,7 +58,6 @@ import (
|
||||||
protoRegistry "git.lumeweb.com/LumeWeb/portal/protocols/registry"
|
protoRegistry "git.lumeweb.com/LumeWeb/portal/protocols/registry"
|
||||||
"git.lumeweb.com/LumeWeb/portal/protocols/s5"
|
"git.lumeweb.com/LumeWeb/portal/protocols/s5"
|
||||||
"github.com/ddo/rq"
|
"github.com/ddo/rq"
|
||||||
"github.com/dnslink-std/go"
|
|
||||||
"github.com/rs/cors"
|
"github.com/rs/cors"
|
||||||
"go.sia.tech/jape"
|
"go.sia.tech/jape"
|
||||||
"go.uber.org/fx"
|
"go.uber.org/fx"
|
||||||
|
@ -565,7 +565,7 @@ func (s *S5API) accountRegister(jc jape.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
newAccount, err := s.accounts.CreateAccount(request.Email, string(passwd))
|
newAccount, err := s.accounts.CreateAccount(request.Email, string(passwd), false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.sendErrorResponse(jc, NewS5Error(ErrKeyStorageOperationFailed, err))
|
s.sendErrorResponse(jc, NewS5Error(ErrKeyStorageOperationFailed, err))
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue