revise_auth 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93ae9905de3248b59ccc8901f7c86b6201e7f40150293dc1f4c49c973a7c5145
4
- data.tar.gz: 4de33a4af773cdcff4ea5a14c40055a89817b4b4acc0214f249740551518284c
3
+ metadata.gz: 44700fedfef11f40ec472b5a3577f9660b04acdde4aa8606a2a2c5e3856c0c09
4
+ data.tar.gz: a76df3e4eeb13822e6b341c49ede1a24a1e78de920d10cf960f1e1e0f4ec360f
5
5
  SHA512:
6
- metadata.gz: 27dbb6e0796fb42449c83ec90916521104f2849cd4b3ed896aea6ebe72ca0478ac8f5d739c74014de0611f53beaee6b1d2395270cf52f4133b7e18dcee39bba0
7
- data.tar.gz: e56b36a7a646737361d0eaa8f6de42353eb24a09ffe26ae6f20b668facf5c4cd45cb009e0397a01495d38bde81dd04d77ebddf5d5ffd373d923bce50464933fd
6
+ metadata.gz: 0b61d98ca68462aaa3adf426c4697ea309487c86dd18ab025d97da78a6835103fce342c275e47500b012f653b8fa5b619085996247a2644a5466c19142d98d3b
7
+ data.tar.gz: 8113dba96e39b285e32007e872de8028e579326e04b8f068e1dcc6d60d0fbb49d3f1116c8469eb105f6b52f1523ceae4c0324b09f2474c83ef6c6818588f1a80
@@ -4,18 +4,18 @@ class ReviseAuth::EmailController < ReviseAuthController
4
4
  # GET /profile/email?confirmation_token=abcdef
5
5
  def show
6
6
  if User.find_by(confirmation_token: params[:confirmation_token])&.confirm_email_change
7
- flash[:notice] = "Your email address has been successfully confirmed."
7
+ flash[:notice] = I18n.t("revise_auth.email_confirmed")
8
8
  user_signed_in?
9
9
  redirect_to (user_signed_in? ? profile_path : root_path)
10
10
  else
11
- redirect_to root_path, alert: "Unable to confirm email address."
11
+ redirect_to root_path, alert: I18n.t("revise_auth.email_confirm_failed")
12
12
  end
13
13
  end
14
14
 
15
15
  def update
16
16
  if current_user.update(email_params)
17
17
  current_user.send_confirmation_instructions
18
- flash[:notice] = "A confirmation email has been sent to #{current_user.unconfirmed_email}"
18
+ flash[:notice] = I18n.t("revise_auth.confirmation_email_sent", email: current_user.unconfirmed_email)
19
19
  end
20
20
 
21
21
  redirect_to profile_path
@@ -3,7 +3,7 @@ class ReviseAuth::PasswordController < ReviseAuthController
3
3
 
4
4
  def update
5
5
  if current_user.update(password_params)
6
- flash[:notice] = "Your password has been changed successfully."
6
+ flash[:notice] = I18n.t("revise_auth.password_changed")
7
7
  end
8
8
 
9
9
  redirect_to profile_path
@@ -14,4 +14,11 @@ class ReviseAuth::PasswordController < ReviseAuthController
14
14
  def password_params
15
15
  params.require(:user).permit(:password, :password_confirmation)
16
16
  end
17
+
18
+ def validate_current_password
19
+ unless current_user.authenticate(params[:current_password])
20
+ flash[:alert] = I18n.t("revise_auth.incorrect_password")
21
+ render "revise_auth/registrations/edit", status: :unprocessable_entity
22
+ end
23
+ end
17
24
  end
@@ -20,7 +20,7 @@ class ReviseAuth::RegistrationsController < ReviseAuthController
20
20
 
21
21
  def update
22
22
  if current_user.update(profile_params)
23
- redirect_to profile_path, notice: "Account updated successfully."
23
+ redirect_to profile_path, notice: I18n.t("revise_auth.account_updated")
24
24
  else
25
25
  render :edit, status: :unprocessable_entity
26
26
  end
@@ -1,8 +1,2 @@
1
1
  class ReviseAuthController < ApplicationController
2
- def validate_current_password
3
- unless current_user.authenticate(params[:current_password])
4
- flash[:alert] = "Your current password is incorrect. Please try again."
5
- render :edit, status: :unprocessable_entity
6
- end
7
- end
8
2
  end
@@ -1,6 +1,16 @@
1
1
  en:
2
2
  revise_auth:
3
3
  account_deleted: "Your account has been deleted."
4
+ account_updated: "Account updated successfully."
5
+
4
6
  invalid_email_or_password: "Invalid email or password."
5
7
  sign_up_or_login: "Sign up or log in to continue."
6
8
 
9
+ # Password changes
10
+ password_changed: "Your password has been changed successfully."
11
+ incorrect_password: "Your current password is incorrect. Please try again."
12
+
13
+ # Email confirmations
14
+ email_confirmed: "Your email address has been successfully confirmed."
15
+ email_confirm_failed: "Unable to confirm email address."
16
+ confirmation_email_sent: "A confirmation email has been sent to %{email}"
data/config/routes.rb CHANGED
@@ -13,6 +13,7 @@ Rails.application.routes.draw do
13
13
  patch "profile/email", to: "email#update"
14
14
  patch "profile/password", to: "password#update"
15
15
 
16
+ # Email confirmation
16
17
  get "profile/email", to: "email#show"
17
18
 
18
19
  delete "logout", to: "sessions#destroy"
@@ -1,3 +1,3 @@
1
1
  module ReviseAuth
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: revise_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver