pull/1198/head
thareekanvar 2 years ago
parent 107a2dbe90
commit acee4380e9

@ -31,10 +31,10 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {
} }
user, err := s.Store.FindUser(ctx, userFind) user, err := s.Store.FindUser(ctx, userFind)
if err != nil && common.ErrorCode(err) != common.NotFound { if err != nil && common.ErrorCode(err) != common.NotFound {
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to find user by username %s", signin.Username)).SetInternal(err) return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Your login credentials are incorrect please check")).SetInternal(err)
} }
if user == nil { if user == nil {
return echo.NewHTTPError(http.StatusUnauthorized, fmt.Sprintf("User not found with username %s", signin.Username)) return echo.NewHTTPError(http.StatusUnauthorized, fmt.Sprintf("Your login credentials are incorrect please check"))
} else if user.RowStatus == api.Archived { } else if user.RowStatus == api.Archived {
return echo.NewHTTPError(http.StatusForbidden, fmt.Sprintf("User has been archived with username %s", signin.Username)) return echo.NewHTTPError(http.StatusForbidden, fmt.Sprintf("User has been archived with username %s", signin.Username))
} }
@ -42,7 +42,7 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {
// Compare the stored hashed password, with the hashed version of the password that was received. // Compare the stored hashed password, with the hashed version of the password that was received.
if err := bcrypt.CompareHashAndPassword([]byte(user.PasswordHash), []byte(signin.Password)); err != nil { if err := bcrypt.CompareHashAndPassword([]byte(user.PasswordHash), []byte(signin.Password)); err != nil {
// If the two passwords don't match, return a 401 status. // If the two passwords don't match, return a 401 status.
return echo.NewHTTPError(http.StatusUnauthorized, "Incorrect password").SetInternal(err) return echo.NewHTTPError(http.StatusUnauthorized, "Your login credentials are incorrect please check").SetInternal(err)
} }
if err = setUserSession(c, user); err != nil { if err = setUserSession(c, user); err != nil {

@ -63,11 +63,11 @@ const Auth = () => {
if (user) { if (user) {
window.location.href = "/"; window.location.href = "/";
} else { } else {
toastHelper.error(t("message.login-failed")); toastHelper.error(t("message.login-failed"),5000);
} }
} catch (error: any) { } catch (error: any) {
console.error(error); console.error(error);
toastHelper.error(error.response.data.error); toastHelper.error(error.response.data.error,5000);
} }
actionBtnLoadingState.setFinish(); actionBtnLoadingState.setFinish();
}; };

Loading…
Cancel
Save