autho 0.0.3 → 0.0.4

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: 921b05c601dc7466f898db7e85a7f7b85f4475d5
4
- data.tar.gz: f90521cd20b2d2ccb85174cd218606f324aa249b
3
+ metadata.gz: 1465ff18d751753c3b8267b4bae37112f4d0ffe7
4
+ data.tar.gz: e336ec06aa26aad931f82e0ec19a19ae9fd815f0
5
5
  SHA512:
6
- metadata.gz: f159369ac5aeefdb2d92b922ab6224220cfa803bf8c2c9d89aff576e8e3c889377df91c633100790c09d57855560aa8c2175968f0d93893ea7aa195008a5e65a
7
- data.tar.gz: 40b801be856023713d7639c2308a88dc03011288225778c6c0b07b875665556227d76694ca60d9e9f34ea2090b65e7f43231b9ab394f176b1d45051495ed4fca
6
+ metadata.gz: 443dd7b7afb1f74c265edc0127bd26257823109c6954fab73ef9dca7b18dea7fd6d2cf70de7fa4ae4c9550324c346ddf7e5ba9a71e4d20a08a83582072c78be1
7
+ data.tar.gz: 1420eca854af30231c72b6122a7b0ce49d92608900a1e6bf8bc9cec9fc4b0f6e09f723122bb55a844e2cafaa2d8bd607cf177426550bff878c795f82b9125db6
data/README.md CHANGED
@@ -26,19 +26,27 @@ Or install it yourself as:
26
26
 
27
27
  ## Usage
28
28
 
29
- Todo. See specs.
29
+ Todo. See `spec` and `examples` dirs.
30
30
 
31
31
  Current parts:
32
32
 
33
33
  * `Autho::Authentication` to find a user from email and password.
34
34
  * `Autho::Session` to store, get and remove user from the session.
35
35
 
36
+ ## Related
37
+
38
+ * [ActiveModel::SecurePassword](http://api.rubyonrails.org/classes/ActiveModel/SecurePassword/ClassMethods.html) for encrypting passwords, validating confirmation etc.
39
+ * [go_to_param](https://github.com/henrik/go_to_param/) to redirect where you wanted to go after logging in.
40
+
41
+
36
42
  ## TODO
37
43
 
38
- * More specs
39
44
  * Polish API
40
- * Depend and document the redirect-after-logging-in gem
45
+ * Replicate SecurePassword?
41
46
  * "Remember me"?
47
+ * Memoize in session?
48
+ * Examples of use in real code, maybe something like a sample app
49
+
42
50
 
43
51
  ## Contributing
44
52
 
@@ -0,0 +1,24 @@
1
+ class ApplicationController < ActionController::Base
2
+ before_filter :ensure_user_is_authenticated
3
+
4
+ def self.skip_user_authentication(opts = {})
5
+ skip_before_filter :ensure_user_is_authenticated, opts
6
+ end
7
+
8
+ def user_session
9
+ @user_session ||= UserSession.new(self, :user_id, User)
10
+ end
11
+
12
+ private
13
+
14
+ def ensure_user_is_authenticated
15
+ unless current_user
16
+ redirect_to login_path, alert: t(:"sessions.must_authenticate")
17
+ end
18
+ end
19
+
20
+ def current_user
21
+ user_session.user
22
+ end
23
+ helper_method :current_user
24
+ end
@@ -0,0 +1,2 @@
1
+ get "login" => "sessions#new", as: :login
2
+ post "login" => "sessions#create"
@@ -0,0 +1 @@
1
+ # TODO
@@ -1,5 +1,6 @@
1
1
  require "autho/version"
2
2
  require "autho/authentication"
3
+ require "autho/session"
3
4
 
4
5
  module Autho
5
6
  end
@@ -1,3 +1,3 @@
1
1
  module Autho
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autho
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Nyh
@@ -93,6 +93,9 @@ files:
93
93
  - README.md
94
94
  - Rakefile
95
95
  - autho.gemspec
96
+ - examples/base_controller.rb
97
+ - examples/routes.rb
98
+ - examples/session_controller.rb
96
99
  - lib/autho.rb
97
100
  - lib/autho/authentication.rb
98
101
  - lib/autho/session.rb