credible 0.3.0 → 0.4.0

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: 2a7e831e22ec5681ca50fa757a380c8bfacca2110ea5198a8b1a1ad756bedef9
4
- data.tar.gz: ec273ca2a4984cc04fcce5a9a335b034258d927c22e7f6c8afecf86ec56d53b6
3
+ metadata.gz: 534ceaffb085783354fb29b8e30cd25fc4bca42282b7c729798cda1e35eb4809
4
+ data.tar.gz: 7a30018164a97fef54c90deb80e92f607039cf1c9604ca740872859c9554bc89
5
5
  SHA512:
6
- metadata.gz: 9c13e39deeedff85915708af06b2dc90b1db47a7f6b47b8d214fc318f958403342e7270ec20bdf73c52679f65478fec51a63ec774b6cc6454300066daa9d9ed9
7
- data.tar.gz: 486785ac185da55edd463932d4b537cb7037901cad30e0842e0c43e1643cd6726e871be790daa8bb6ec62f5cf81ab717dccaade94150300717f03517b2900cf8
6
+ metadata.gz: 1ef0e645f4f52194c7244ae550ca50c17e073e27b6c420b3a8f57ab92e284be098959f6af2fa926a05530c351d7c59206bbcfb5f9825c6f9212a4fe7f7fe128a
7
+ data.tar.gz: 7f7f48f126f381505c8c73c1122a249f47421d2feef5a84a726de35a8bb09a1f7e0650a64bcdcbcc7009d0895e4b7e04ec912838d4e0fb49f0b1f0cb6d257ca9
@@ -32,10 +32,10 @@ class Credible::Authentication::UsersController < Credible::AuthenticationContro
32
32
  # GET /users/confirm/:confirmation_token
33
33
  # GET /users/confirm/:confirmation_token.json
34
34
  def confirm
35
- @user = ::User.find_by(confirmation_token: params[:confirmation_token])
35
+ @user = ::User.find_by(email: params[:email])
36
36
  authorize @user
37
37
 
38
- @user.confirm
38
+ @user.confirm(params[:confirmation_token])
39
39
 
40
40
  if @user.save
41
41
  @session = current_user ? current_session : ::Session.create(user: @user)
@@ -5,7 +5,7 @@ class Credible::UserMailer < ApplicationMailer
5
5
  @app_name = Rails.application.class.module_parent_name
6
6
  @user = params[:user]
7
7
  @url = root_url
8
- @confirmation_url = @url + 'confirm/' + @user.confirmation_token
8
+ @confirmation_url = @url + 'confirm/' + @user.confirmation_token + '?email=' + @user.email
9
9
  mail(to: @user.email, subject: "Welcome to #{@app_name} | Please confirm your account")
10
10
  end
11
11
 
data/lib/credible/user.rb CHANGED
@@ -20,10 +20,12 @@ module Credible
20
20
  validates_confirmation_of :password, allow_blank: true
21
21
  # End custom password validation
22
22
 
23
- def confirm
24
- self.confirmation_token = nil
25
- self.password = SecureRandom.hex(8) unless password_digest.present?
26
- self.confirmed_at = Time.now.utc
23
+ def confirm(token = nil)
24
+ if ActiveSupport::SecurityUtils.secure_compare(token, confirmation_token)
25
+ self.confirmation_token = nil
26
+ self.password = SecureRandom.hex(8) unless password_digest.present?
27
+ self.confirmed_at = Time.now.utc
28
+ end
27
29
  end
28
30
 
29
31
  def confirmed?
@@ -1,3 +1,3 @@
1
1
  module Credible
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: credible
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thom Bruce