authentasaurus 0.5.14 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- <p>You've been invited to create an account at your-domain.com follow this <%= link_to "link", new_registrations_url(:token => @token) %> to respond to the invitation.</p>
1
+ <p>You've been invited to create an account at <%= AUTHENTASAURUS[:mail][:host] %> follow this <%= link_to "link", new_registrations_url(:host => AUTHENTASAURUS[:mail][:host], :token => @token) %> to respond to the invitation.</p>
2
2
 
3
3
  <p>Best Regards,</p>
4
- <p>your-domain.com Team</p>
4
+ <p><%= AUTHENTASAURUS[:mail][:host] %> Team</p>
@@ -1,7 +1,7 @@
1
1
  <p>Dear <%= @name %>,</p>
2
2
 
3
3
  <p>A request has been made to recover your account's password.</p>
4
- <p>Please visit this <%= link_to "link", recover_password_url(@token) %> and follow the instructions.</p>
4
+ <p>Please visit this <%= link_to "link", recover_password_url(:host => AUTHENTASAURUS[:mail][:host], @token) %> and follow the instructions.</p>
5
5
 
6
6
  <p>Best Regards,</p>
7
- <p>your-domain.com Team</p>
7
+ <p><%= AUTHENTASAURUS[:mail][:host] %> Team</p>
@@ -1,6 +1,6 @@
1
1
  <p>Dear <%= @name %>,</p>
2
2
 
3
- <p>Please validate your account at your-domain.com by visiting this <%= link_to "link", validate_url, :code => @vcode %>.</p>
3
+ <p>Please validate your account at <%= AUTHENTASAURUS[:mail][:host] %> by visiting this <%= link_to "link", validate_url(:host => AUTHENTASAURUS[:mail][:host] , :code => @vcode) %>.</p>
4
4
 
5
5
  <p>Best Regards,</p>
6
- <p>your-domain.com Team</p>
6
+ <p><%= AUTHENTASAURUS[:mail][:host] %> Team</p>
@@ -1,7 +1,9 @@
1
1
  ## Authentasaurus configuration
2
2
  development: &non_production_settings
3
+ :hashing: "SHA2" # MD5 - SHA1 - SHA2
3
4
  :mail:
4
5
  :email: &development_email "foo_bar@your-domain.com"
6
+ :host: "http://localhost:3000/"
5
7
  :modules:
6
8
  :remote:
7
9
  :user:
@@ -27,8 +29,10 @@ test:
27
29
  <<: *non_production_settings
28
30
 
29
31
  production:
32
+ :hashing: "SHA2" # MD5 - SHA1 - SHA2
30
33
  :mail:
31
34
  :email: &production_email "foo_bar@your-domain.com"
35
+ :host: "http://your_website.com/"
32
36
  :modules:
33
37
  :remote:
34
38
  :user:
@@ -4,9 +4,9 @@ Description:
4
4
  Examples:
5
5
  `./script/generate authentasaurus_views users`
6
6
 
7
- creates views for Authentasaurus with main user model named "user"
7
+ creates views for Authentasaurus with main user model named "user" and controller named "users"
8
8
 
9
- `./script/generate authentasaurus_views users --authorizable --validatable
9
+ `./script/generate authentasaurus_views users --authorizable --validatable --invitable
10
10
 
11
11
  creates views for Authentasaurus with main user model named "user" and also creates views
12
- for authorization (--authorizable) and validation (--validatable)
12
+ for authorization (--authorizable), invitation (--invitable) and validation (--validatable)
@@ -23,6 +23,7 @@ class AuthentasaurusViewsGenerator < Rails::Generator::NamedBase
23
23
  ## recoverable
24
24
  m.file 'views/recoveries/new.html.erb', File.join("app/views", class_path, "recoveries", "new.html.erb")
25
25
  m.file 'views/recoveries/edit.html.erb', File.join("app/views", class_path, "recoveries", "edit.html.erb")
26
+ m.file 'views/authentasaurus_emailer/recovery_mail.html.erb', File.join("app/views", class_path, "authentasaurus_emailer", "recovery_mail.html.erb")
26
27
 
27
28
 
28
29
  if options[:authorizable]
@@ -1,4 +1,4 @@
1
- <p>You've been invited to create an account at your-domain.com follow this <%= link_to "link", new_registrations_url(:token => @token) %> to respond to the invitation.</p>
1
+ <p>You've been invited to create an account at <%= AUTHENTASAURUS[:mail][:host] %> follow this <%= link_to "link", new_registrations_url(:host => AUTHENTASAURUS[:mail][:host], :token => @token) %> to respond to the invitation.</p>
2
2
 
3
3
  <p>Best Regards,</p>
4
- <p>your-domain.com Team</p>
4
+ <p><%= AUTHENTASAURUS[:mail][:host] %> Team</p>
@@ -1,7 +1,7 @@
1
1
  <p>Dear <%= @name %>,</p>
2
2
 
3
3
  <p>A request has been made to recover your account's password.</p>
4
- <p>Please visit this <%= link_to "link", recover_password_url(@token) %> and follow the instructions.</p>
4
+ <p>Please visit this <%= link_to "link", recover_password_url(:host => AUTHENTASAURUS[:mail][:host], @token) %> and follow the instructions.</p>
5
5
 
6
6
  <p>Best Regards,</p>
7
- <p>your-domain.com Team</p>
7
+ <p><%= AUTHENTASAURUS[:mail][:host] %> Team</p>
@@ -1,6 +1,6 @@
1
1
  <p>Dear <%= @name %>,</p>
2
2
 
3
- <p>Please validate your account at your-domain.com by visiting this <%= link_to "link", validate_url, :code => @vcode %>.</p>
3
+ <p>Please validate your account at <%= AUTHENTASAURUS[:mail][:host] %> by visiting this <%= link_to "link", validate_url(:host => AUTHENTASAURUS[:mail][:host] , :code => @vcode) %>.</p>
4
4
 
5
5
  <p>Best Regards,</p>
6
- <p>your-domain.com Team</p>
6
+ <p><%= AUTHENTASAURUS[:mail][:host] %> Team</p>
@@ -5,7 +5,19 @@ module ActiveRecord::ActsAsAuthenticatable
5
5
  end
6
6
 
7
7
  module ClassMethods
8
- require 'digest/sha1'
8
+
9
+ case AUTHENTASAURUS[:hashing]
10
+ when "SHA2"
11
+ require 'digest/sha2'
12
+ when "SHA1"
13
+ require 'digest/sha1'
14
+ when "MD5"
15
+ require 'digest/md5'
16
+ else
17
+ require 'digest/sha2'
18
+ end
19
+
20
+
9
21
  ## Authenticates the username and password
10
22
  def authenticate(username, password)
11
23
  user=self.find_by_username username
@@ -19,7 +31,18 @@ module ActiveRecord::ActsAsAuthenticatable
19
31
  ## Encrypts the password using the given seed
20
32
  def encrypt_password(password, password_seed)
21
33
  pass_to_hash=password + "Securasaurus" + password_seed
22
- Digest::SHA1.hexdigest(pass_to_hash)
34
+
35
+ case AUTHENTASAURUS[:hashing]
36
+ when "SHA2"
37
+ Digest::SHA2.hexdigest(pass_to_hash)
38
+ when "SHA1"
39
+ Digest::SHA1.hexdigest(pass_to_hash)
40
+ when "MD5"
41
+ Digest::MD5.hexdigest(pass_to_hash)
42
+ else
43
+ Digest::SHA2.hexdigest(pass_to_hash)
44
+ end
45
+
23
46
  end
24
47
  end
25
48
 
@@ -21,11 +21,17 @@ module ActiveResource::ActsAsAuthenticatable
21
21
  last_update = user.attributes.delete "updated_at"
22
22
  local_user = self.sync_to.find_or_initialize_by_username user.username, user.attributes
23
23
 
24
- last_update_datetime = (last_update.kind_of?(String)) ? (DateTime.parse(last_update)) : (last_update)
25
-
26
- if local_user.updated_at < last_update_datetime
27
- local_user.update_attributes user.attributes
24
+ unless local_user.new_record?
25
+ last_update_datetime = (last_update.kind_of?(String)) ? (DateTime.parse(last_update)) : (last_update)
26
+
27
+ if local_user.updated_at < last_update_datetime
28
+ local_user.update_attributes user.attributes
29
+ end
30
+ else
31
+ local_user.save
28
32
  end
33
+
34
+ user = local_user
29
35
  end
30
36
  end
31
37
  return user
@@ -2,6 +2,8 @@ require 'active_resource/acts_as_authenticatable'
2
2
  module ActiveResource::Authenticatable
3
3
  def self.included(base)
4
4
  base.send :extend, ClassMethods
5
+
6
+ base.send :unloadable
5
7
  end
6
8
 
7
9
  module ClassMethods
@@ -5,6 +5,8 @@ module Authentasaurus::Models::Recovery
5
5
 
6
6
  base.send :require, "digest/sha1"
7
7
 
8
+ base.send :unloadable
9
+
8
10
  base.send :belongs_to, :user
9
11
 
10
12
  base.send :before_validation_on_create, :make_token!
@@ -3,7 +3,7 @@ module Authentasaurus::Models::UserInvitation
3
3
  base.send :extend, ClassMethods
4
4
  base.send :include, InstanceMethods
5
5
 
6
- base.send :require, 'digest/sha1'
6
+ base.send :require, 'digest/sha2'
7
7
  base.send :validates_presence_of, :email
8
8
  base.send :validates_uniqueness_of, :email, :scope => :token
9
9
  base.send :validates_format_of, :email, :with => %r{[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}}
@@ -25,7 +25,7 @@ module Authentasaurus::Models::UserInvitation
25
25
  def create_token
26
26
  return if self.email.nil? || self.email.blank?
27
27
  string_to_hash=self.email + "invitable.olation" + self.email.hash.to_s
28
- self.token = Digest::SHA1.hexdigest(string_to_hash)
28
+ self.token = Digest::SHA2.hexdigest(string_to_hash)
29
29
  end
30
30
  end
31
31
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authentasaurus
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 5
9
- - 14
10
- version: 0.5.14
8
+ - 6
9
+ - 0
10
+ version: 0.6.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Omar Mekky