mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-29 18:19:39 +02:00
Add auth-related i18n
This commit is contained in:
parent
532cd08b32
commit
40c6c4b756
5 changed files with 32 additions and 39 deletions
|
@ -1,6 +1,8 @@
|
||||||
class PasswordResetsController < ApplicationController
|
class PasswordResetsController < ApplicationController
|
||||||
layout "auth"
|
layout "auth"
|
||||||
|
|
||||||
|
before_action :set_user_by_token, only: :update
|
||||||
|
|
||||||
def new
|
def new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -12,7 +14,7 @@ class PasswordResetsController < ApplicationController
|
||||||
).password_reset.deliver_later
|
).password_reset.deliver_later
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
@ -20,7 +22,7 @@ class PasswordResetsController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
if @user.update(password_params)
|
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
|
else
|
||||||
render :edit, status: :unprocessable_entity
|
render :edit, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
@ -30,7 +32,7 @@ class PasswordResetsController < ApplicationController
|
||||||
|
|
||||||
def set_user_by_token
|
def set_user_by_token
|
||||||
@user = User.find_by_token_for(password_reset: params[: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
|
end
|
||||||
|
|
||||||
def password_params
|
def password_params
|
||||||
|
|
|
@ -6,7 +6,7 @@ class PasswordsController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
if current_user.update(password_params)
|
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
|
else
|
||||||
render :edit, status: :unprocessable_entity
|
render :edit, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,10 +14,10 @@ class RegistrationsController < ApplicationController
|
||||||
|
|
||||||
if @user.save
|
if @user.save
|
||||||
login @user
|
login @user
|
||||||
flash[:notice] = "You have signed up successfully."
|
flash[:notice] = t(".success")
|
||||||
redirect_to root_path
|
redirect_to root_path
|
||||||
else
|
else
|
||||||
flash[:alert] = "Invalid input, please try again."
|
flash[:alert] = t(".failure")
|
||||||
render :new
|
render :new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -34,7 +34,7 @@ class RegistrationsController < ApplicationController
|
||||||
|
|
||||||
def claim_invite_code
|
def claim_invite_code
|
||||||
unless InviteCode.claim! params[:user][: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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,13 +9,13 @@ class SessionsController < ApplicationController
|
||||||
login user
|
login user
|
||||||
redirect_to root_path
|
redirect_to root_path
|
||||||
else
|
else
|
||||||
flash.now[:alert] = "Invalid email or password."
|
flash.now[:alert] = t(".invalid_credentials")
|
||||||
render :new, status: :unprocessable_entity
|
render :new, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
logout
|
logout
|
||||||
redirect_to root_path, notice: "You have signed out successfully."
|
redirect_to root_path, notice: t(".logout_successful")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,31 +1,22 @@
|
||||||
# Files in the config/locales directory are used for internationalization and
|
---
|
||||||
# are automatically loaded by Rails. If you want to use locales other than
|
|
||||||
# English, add the necessary files in this directory.
|
|
||||||
#
|
|
||||||
# To use the locales, use `I18n.t`:
|
|
||||||
#
|
|
||||||
# I18n.t "hello"
|
|
||||||
#
|
|
||||||
# In views, this is aliased to just `t`:
|
|
||||||
#
|
|
||||||
# <%= t("hello") %>
|
|
||||||
#
|
|
||||||
# To use a different locale, set it with `I18n.locale`:
|
|
||||||
#
|
|
||||||
# I18n.locale = :es
|
|
||||||
#
|
|
||||||
# This would use the information in config/locales/es.yml.
|
|
||||||
#
|
|
||||||
# To learn more about the API, please read the Rails Internationalization guide
|
|
||||||
# at https://guides.rubyonrails.org/i18n.html.
|
|
||||||
#
|
|
||||||
# Be aware that YAML interprets the following case-insensitive strings as
|
|
||||||
# booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings
|
|
||||||
# must be quoted to be interpreted as strings. For example:
|
|
||||||
#
|
|
||||||
# en:
|
|
||||||
# "yes": yup
|
|
||||||
# enabled: "ON"
|
|
||||||
|
|
||||||
en:
|
en:
|
||||||
hello: "Hello world"
|
password_resets:
|
||||||
|
create:
|
||||||
|
requested: If an account with that email exists, we have sent a link to reset
|
||||||
|
your password.
|
||||||
|
update:
|
||||||
|
invalid_token: Invalid token.
|
||||||
|
success: Your password has been reset.
|
||||||
|
passwords:
|
||||||
|
update:
|
||||||
|
success: Your password has been updated successfully.
|
||||||
|
registrations:
|
||||||
|
create:
|
||||||
|
failure: Invalid input, please try again.
|
||||||
|
invalid_invite_code: Invalid invite code, please try again.
|
||||||
|
success: You have signed up successfully.
|
||||||
|
sessions:
|
||||||
|
create:
|
||||||
|
invalid_credentials: Invalid email or password.
|
||||||
|
destroy:
|
||||||
|
logout_successful: You have signed out successfully.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue