chore: extract mail to it's own service #181
Some checks failed
Build Docker Image / Explore-Gitea-Actions (push) Failing after 45s
Some checks failed
Build Docker Image / Explore-Gitea-Actions (push) Failing after 45s
This commit is contained in:
@@ -76,7 +76,7 @@ func (handler HandlerAuthImpl) handleSignIn() http.HandlerFunc {
|
||||
http.Error(w, "Invalid email or password", http.StatusUnauthorized)
|
||||
} else {
|
||||
utils.LogError("Error signing in", err)
|
||||
http.Error(w, "An error occurred", http.StatusInternalServerError)
|
||||
http.Error(w, "InternalServerErr", http.StatusInternalServerError)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
11
handler/auth_test.go
Normal file
11
handler/auth_test.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestHandleSignIn(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("should signIn and return session cookie", func(t *testing.T) {
|
||||
})
|
||||
}
|
||||
@@ -400,6 +400,7 @@ func HandleDeleteAccountComp(db *sql.DB, serverSettings *types.ServerSettings) h
|
||||
return
|
||||
}
|
||||
|
||||
mailService := NewMailService(serverSettings)
|
||||
go mailService.SendMail(user.Email, "Account deleted", "Your account has been deleted")
|
||||
|
||||
utils.DoRedirect(w, r, "/")
|
||||
@@ -579,6 +580,7 @@ func HandleResetPasswordComp(db *sql.DB, serverSettings *types.ServerSettings) h
|
||||
utils.TriggerToast(w, r, "error", "Internal Server Error")
|
||||
return
|
||||
}
|
||||
mailService := NewMailService(serverSettings)
|
||||
mailService.SendMail(email, "Reset Password", mail.String())
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ func TestSignIn(t *testing.T) {
|
||||
),
|
||||
err: nil,
|
||||
}
|
||||
underTest := NewServiceAuthImpl(stub)
|
||||
underTest := NewServiceAuthImpl(stub, NewServiceMailStub())
|
||||
|
||||
actualUser, err := underTest.SignIn("test@test.de", "password")
|
||||
if err != nil {
|
||||
@@ -71,7 +71,7 @@ func TestSignIn(t *testing.T) {
|
||||
),
|
||||
err: nil,
|
||||
}
|
||||
underTest := NewServiceAuthImpl(stub)
|
||||
underTest := NewServiceAuthImpl(stub, NewServiceMailStub())
|
||||
|
||||
_, err := underTest.SignIn("test@test.de", "wrong password")
|
||||
if err != ErrInvaidCredentials {
|
||||
@@ -84,7 +84,7 @@ func TestSignIn(t *testing.T) {
|
||||
user: nil,
|
||||
err: db.ErrUserNotFound,
|
||||
}
|
||||
underTest := NewServiceAuthImpl(stub)
|
||||
underTest := NewServiceAuthImpl(stub, NewServiceMailStub())
|
||||
|
||||
_, err := underTest.SignIn("test", "test")
|
||||
if err != ErrInvaidCredentials {
|
||||
@@ -97,7 +97,7 @@ func TestSignIn(t *testing.T) {
|
||||
user: nil,
|
||||
err: errors.New("Some error"),
|
||||
}
|
||||
underTest := NewServiceAuthImpl(stub)
|
||||
underTest := NewServiceAuthImpl(stub, NewServiceMailStub())
|
||||
|
||||
_, err := underTest.SignIn("test", "test")
|
||||
if err != types.ErrInternal {
|
||||
|
||||
Reference in New Issue
Block a user