authem 1.1.1 → 1.2.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
  SHA1:
3
- metadata.gz: 989e6a3f6802473f1334d4305f403483d36bc349
4
- data.tar.gz: c5e6b740c35e15336a52a8b7db8baec3c6b9c52c
3
+ metadata.gz: c3646171f30266e642adb08a68757e316615fb89
4
+ data.tar.gz: 5fc83cca465109e6d677b1aa18899ee0eba21dbc
5
5
  SHA512:
6
- metadata.gz: 21ecd5a0a4c99aadf9585efe6d7ff7faec70a8cb61f6c6ceb6ce63d183f7c032ff4dc097dbaa14c26c6fee3b0235fd845d33ad0ee14fe206bff6cb9ac9d24487
7
- data.tar.gz: efb5b02291d31b50cd9a31ae8e58b31e3ad5ff17ad9acc4566abcb4ee921c5f6bfa8abec66a16fdbaf79ca7fd3ee990a03b8c116405f90765bd471c626bc835d
6
+ metadata.gz: 1d6a97270123f9e64a680a426ae9b9578f53bde413f89ec9c7eb37c9fa28229c5c7efa4e4faa34479a6e8edf3b50658ca581f272263d55b97eac1ad26100ebc0
7
+ data.tar.gz: 6ac194d7e261dc8151f2d2fc69ed6ff34129e6c3465a001dc6910bd1b763d7d78d610fa842ccd5ec5ae1aeb1f2daa864a6c2739a82e22bad3efacf84679486e4
@@ -1,169 +1,16 @@
1
- # Authem
1
+ # Overview
2
2
 
3
- Authem is an email-based authentication library for Ruby web applications. It ONLY supports email/password authentication. It does not automatically integrate with Twitter, Facebook, or whatever oauth or SSO service you like the best. It is meant to handle user security but allow you to fully customize your user account behavior because the code is all yours.
3
+ ## About Authem
4
+
5
+ Authem is an email-based authentication library for ruby web apps.
4
6
 
5
7
  ## Compatibility
6
8
 
7
- Authem is tested against Ruby 1.9.2, 1.9.3, 2.0.0, and Rubinius
9
+ Authem is tested against Ruby 1.9.3, 2.0.0, and Rubinius.
8
10
 
9
11
  [![Build Status](https://secure.travis-ci.org/paulelliott/authem.png)](http://travis-ci.org/paulelliott/authem)
10
12
  [![Code Climate](https://codeclimate.com/github/paulelliott/authem.png)](https://codeclimate.com/github/paulelliott/authem)
11
13
 
12
- ## Installation
13
-
14
- Add the following to your project's Gemfile:
15
-
16
- gem 'authem'
17
-
18
- Or for Rails 4:
19
-
20
- gem 'authem', github: 'paulelliott/authem', branch: 'rails4'
21
-
22
- ## Usage
23
-
24
- ### Model Setup
25
-
26
- Tell authem which of your classes will be used for authentication in `config/initializers/authem.rb`
27
-
28
- Authem.configure do |config|
29
- config.user_class = User
30
- end
31
-
32
- Once you've decided which class to use for authentication, make sure it has
33
- the right stuff in the database.
34
-
35
- create_table :users do |t|
36
- t.column :email, :string
37
- t.column :password_digest, :string
38
- t.column :remember_token, :string
39
- t.column :reset_password_token, :string
40
- t.column :session_token, :string
41
- end
42
-
43
- Then in your model
44
-
45
- include Authem::User
46
-
47
- #### Model Usage
48
-
49
- Now that your class is all set up using Authem...
50
-
51
- Provide your instance with the following attributes:
52
-
53
- * email
54
- * password
55
- * password\_confirmation
56
-
57
- Example:
58
-
59
- User.new(
60
- email: 'matt@example.com',
61
- password: '$ushi',
62
- password_confirmation: '$ushi'
63
- )
64
-
65
- When saved, the password is hashed and stored as `password_digest` in your
66
- database.
67
-
68
- ### Controller Usage
69
-
70
- In your application controller:
71
-
72
- include Authem::ControllerSupport
73
-
74
- Which gives you access to
75
-
76
- * `sign_in`
77
- * `sign_out`
78
- * `current_user`
79
- * `require_user`
80
- * `signed_in?`
81
- * `redirect_back_or_to`
82
-
83
- Then require authentication for a whole controller or action(s) with:
84
-
85
- before_filter :require_user, only: [:edit, :update]
86
-
87
- Or get even crazier:
88
-
89
- before_filter :maybe_require_user_under_certain_circumstances
90
-
91
- private
92
-
93
- def maybe_require_user_under_certain_circumstances
94
- require_user if sky.blue? and rain.expected?
95
- end
96
-
97
- For signing in/out users, try a SessionsController like the following
98
-
99
- class UserSessionsController < ApplicationController
100
- //works best with decent_exposure :)
101
- expose(:user) { User.find_by_email(params[:email]) }
102
-
103
- // expects params: { email: 'foo@example.com', password: 'bar' }
104
- def create
105
- if user && user.authenticate(params[:password])
106
- sign_in(user)
107
- redirect_back_or_to(:profile)
108
- else
109
- flash.now.alert = "Your email and password do not match"
110
- render :new
111
- end
112
- end
113
-
114
- def destroy
115
- sign_out
116
- redirect_to :root
117
- end
118
- end
119
-
120
- Resetting passwords is a little more involved, but would look like this:
121
-
122
- class PasswordResetsController < ApplicationController
123
- //works best with decent_exposure :)
124
- expose(:user_by_email) { User.find_by_email(params[:email]) }
125
- expose(:user_by_token) { User.find_by_reset_password_token(params[:id]) }
126
- expose(:reset_password_email) { UserMailer.reset_password_email(user_by_email) }
127
-
128
- before_filter :verify_user, only: [:edit, :update]
129
-
130
- // expects params: { email: 'foo@example.com' }
131
- def create
132
- reset_password_email.deliver if user_by_email
133
- redirect_to [:new, :password_reset], alert: "Instructions for resetting your password have been sent to #{params[:email]}"
134
- end
135
-
136
- // expects params: { user: { password: 'bar', password_confirmation: 'bar' } }
137
- def update
138
- if user_by_token.reset_password(params[:user][:password], params[:user][:password_confirmation])
139
- sign_in(user_by_token)
140
- redirect_to :root
141
- else
142
- render :edit
143
- end
144
- end
145
-
146
- protected
147
-
148
- def verify_user
149
- unless user_by_token
150
- redirect_to [:new, :password_reset], alert: "We can't find your account with that token. You should try requesting another one."
151
- end
152
- end
153
- end
154
-
155
-
156
- ## Configuration
157
-
158
- Authem lets you configure the user class:
159
-
160
- Authem.configure do |config|
161
- config.user_class = Admin
162
- end
163
-
164
- ## Contribute
165
-
166
- Pull requests are welcome; please provide spec coverage for new code.
14
+ ## Documentation
167
15
 
168
- * `bundle install`
169
- * `rake`
16
+ Please see the Authem website for up-to-date documentation: http://authem.org
@@ -10,7 +10,7 @@ module Authem::BaseUser
10
10
 
11
11
  module ClassMethods
12
12
  def find_by_email(email)
13
- where("LOWER(email) = ?", email.downcase).first
13
+ find_by("lower(email) = ?", email.downcase)
14
14
  end
15
15
  end
16
16
 
@@ -25,7 +25,7 @@ module Authem::ControllerSupport
25
25
  end
26
26
 
27
27
  def require_user
28
- unless current_user
28
+ unless signed_in?
29
29
  session[:return_to_url] = request.url unless request.xhr?
30
30
  redirect_to Authem::Config.sign_in_path
31
31
  end
@@ -1,3 +1,3 @@
1
1
  module Authem
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Elliott
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-24 00:00:00.000000000 Z
11
+ date: 2013-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 4.0.0.rc1
19
+ version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 4.0.0.rc1
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bcrypt-ruby
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: 4.0.0.rc1
47
+ version: '4.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 4.0.0.rc1
54
+ version: '4.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activerecord
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 4.0.0.rc1
61
+ version: '4.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: 4.0.0.rc1
68
+ version: '4.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: database_cleaner
71
71
  requirement: !ruby/object:Gem::Requirement