mirror of
https://github.com/we-promise/sure.git
synced 2026-04-16 10:34:09 +00:00
Centralize auth messages (#269)
* Add i18n-tasks * Add auth-related i18n * Centralize auth messages * Remove safe navigation * Revert "Remove safe navigation" This reverts commit 56b5e01e5e0ab9f54a9a5d9f5559e29897d239a4. * Remove newline in Gemfile
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
class PasswordResetsController < ApplicationController
|
||||
layout "auth"
|
||||
|
||||
before_action :set_user_by_token, only: :update
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
@@ -12,7 +14,7 @@ class PasswordResetsController < ApplicationController
|
||||
).password_reset.deliver_later
|
||||
end
|
||||
|
||||
redirect_to root_path, notice: "If an account with that email exists, we have sent a link to reset your password."
|
||||
redirect_to root_path, notice: t(".requested")
|
||||
end
|
||||
|
||||
def edit
|
||||
@@ -20,7 +22,7 @@ class PasswordResetsController < ApplicationController
|
||||
|
||||
def update
|
||||
if @user.update(password_params)
|
||||
redirect_to new_session_path, notice: "Your password has been reset."
|
||||
redirect_to new_session_path, notice: t(".success")
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
@@ -30,7 +32,7 @@ class PasswordResetsController < ApplicationController
|
||||
|
||||
def set_user_by_token
|
||||
@user = User.find_by_token_for(password_reset: params[:token])
|
||||
redirect_to new_password_reset_path, alert: "Invalid token." unless @user.present?
|
||||
redirect_to new_password_reset_path, alert: t("password_resets.update.invalid_token") unless @user.present?
|
||||
end
|
||||
|
||||
def password_params
|
||||
|
||||
@@ -6,7 +6,7 @@ class PasswordsController < ApplicationController
|
||||
|
||||
def update
|
||||
if current_user.update(password_params)
|
||||
redirect_to root_path, notice: "Your password has been updated successfully."
|
||||
redirect_to root_path, notice: t(".success")
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
|
||||
@@ -14,10 +14,10 @@ class RegistrationsController < ApplicationController
|
||||
|
||||
if @user.save
|
||||
login @user
|
||||
flash[:notice] = "You have signed up successfully."
|
||||
flash[:notice] = t(".success")
|
||||
redirect_to root_path
|
||||
else
|
||||
flash[:alert] = "Invalid input, please try again."
|
||||
flash[:alert] = t(".failure")
|
||||
render :new
|
||||
end
|
||||
end
|
||||
@@ -34,7 +34,7 @@ class RegistrationsController < ApplicationController
|
||||
|
||||
def claim_invite_code
|
||||
unless InviteCode.claim! params[:user][:invite_code]
|
||||
redirect_to new_registration_path, alert: "Invalid invite code, please try again."
|
||||
redirect_to new_registration_path, alert: t("registrations.create.invalid_invite_code")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,13 +9,13 @@ class SessionsController < ApplicationController
|
||||
login user
|
||||
redirect_to root_path
|
||||
else
|
||||
flash.now[:alert] = "Invalid email or password."
|
||||
flash.now[:alert] = t(".invalid_credentials")
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
logout
|
||||
redirect_to root_path, notice: "You have signed out successfully."
|
||||
redirect_to root_path, notice: t(".logout_successful")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user