active_model-session 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +4 -4
- data/lib/active_model/session.rb +7 -1
- data/lib/active_model/session/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5cd57a6ead747a4e20a597a5edc00a34492c079
|
4
|
+
data.tar.gz: bf772c5f0ce5b3d9c706a4c82a63f75518acdbb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e36159deb0d78806505812cb335cd5d12a4da16c5576196edffe4e1a4e7859a6e6983a822729411d8c497cc0bbad60facf6c5b1adfb583ae458bf989b647e81
|
7
|
+
data.tar.gz: 869f0416c0eabf1808b95bfe78c4a1b4c30387b773c66e1441c9dd8d85663f0c404dc53b2941fc9312b7b52288456ebc0741ba78a3a1090c7e2559e88d7d10ce
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# ActiveModel::Session
|
2
2
|
|
3
|
-
`ActiveModel::Session` is a lightweight session model implemented
|
3
|
+
`ActiveModel::Session` is a lightweight session model implemented
|
4
4
|
on top of `ActiveModel::Model`.
|
5
5
|
|
6
6
|
## Installation
|
@@ -21,7 +21,7 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
The most popular workflow is:
|
23
23
|
|
24
|
-
class
|
24
|
+
class SessionsController < ApplicationController
|
25
25
|
def new
|
26
26
|
@session = ActiveModel::Session.new
|
27
27
|
end
|
@@ -39,7 +39,7 @@ The most popular workflow is:
|
|
39
39
|
private
|
40
40
|
|
41
41
|
def session_params
|
42
|
-
params.require(:
|
42
|
+
params.require(:active_model_session).permit(:email, :password)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -64,4 +64,4 @@ session model and override some defaults:
|
|
64
64
|
|
65
65
|
## Copyright
|
66
66
|
|
67
|
-
Copyright ©
|
67
|
+
Copyright © 2014 Kuba Kuźma. See LICENSE for details.
|
data/lib/active_model/session.rb
CHANGED
@@ -5,7 +5,8 @@ module ActiveModel
|
|
5
5
|
class Session
|
6
6
|
include Model
|
7
7
|
|
8
|
-
attr_accessor :password
|
8
|
+
attr_accessor :password
|
9
|
+
attr_writer :user
|
9
10
|
attr_reader :email
|
10
11
|
|
11
12
|
validates :email, presence: true, if: -> { user.blank? }
|
@@ -14,7 +15,12 @@ module ActiveModel
|
|
14
15
|
delegate :id, :authenticate, to: :user, prefix: true, allow_nil: true
|
15
16
|
|
16
17
|
def email=(email)
|
18
|
+
remove_instance_variable(:@user) if defined?(@user)
|
17
19
|
@email = email
|
20
|
+
end
|
21
|
+
|
22
|
+
def user
|
23
|
+
return @user if defined?(@user)
|
18
24
|
@user = User.find_by(email: email)
|
19
25
|
end
|
20
26
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_model-session
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kuba Kuźma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|