authstrategies 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmMxNWM2NDI3YWFhYmIzNjZkYTM3MTYwOGRjOTg3NThkZmM5NTM3MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NTQyNDgzY2E2ZGYwM2UxNGQxODc4ZTExNmYxZTY5ZGU0MmU2ZDFhZg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTExZWRhMTNmZmNmOTJlN2Q1NWM3MDAxZjI1ZDc0NzEzZWVkOWJlNjNmOWFk
|
10
|
+
OGM0YWE0MzM0NGU0YzNhZTI2YjQ3MjY4NmYyZjZlMzBlM2EwMjliNjlkOWY1
|
11
|
+
YjMwNTBkYzZjZGY2OWEwYzZiMjc4YjY2OTA4ZjQ5N2FjNzNjMGU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NjEzMjI1YjliZWViZDU2Y2FlNzRkZTUxYWZjMmJmNDI3NjZhOWNiYzRlNGZj
|
14
|
+
MDc0OWQ1MDQ5MzQ3ODc3ZTRiNGIwMjRhNjI3NDNhYWNiMTQ4ZGFkNzM4MGJi
|
15
|
+
ODAyZTEyMjkwODNlYjExZjk0ZWRiOTE2MTEzOGQ4ZDkyZTMwMWU=
|
data/lib/authstrategies.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authstrategies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dobromir Ivanov
|
@@ -124,10 +124,7 @@ files:
|
|
124
124
|
- authstrategies.gemspec
|
125
125
|
- lib/authstrategies.rb
|
126
126
|
- lib/authstrategies/helpers.rb
|
127
|
-
- lib/authstrategies/models/User.rb
|
128
127
|
- lib/authstrategies/version.rb
|
129
|
-
- lib/authstrategies/views/login.erb
|
130
|
-
- lib/authstrategies/views/signup.erb
|
131
128
|
homepage: ''
|
132
129
|
licenses:
|
133
130
|
- MIT
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'bcrypt'
|
2
|
-
require 'activerecord'
|
3
|
-
|
4
|
-
class User < ActiveRecord::Base
|
5
|
-
include BCrypt
|
6
|
-
|
7
|
-
validates :email, :password, presence: true
|
8
|
-
validates :email, uniqueness: true
|
9
|
-
|
10
|
-
validates :password, confirmation: true
|
11
|
-
validates :password, length: { in: 8..20,
|
12
|
-
too_long: "%{count} is the maximum allowed!",
|
13
|
-
too_short: "must be at least %{count}" }
|
14
|
-
|
15
|
-
before_save :encrypt_password
|
16
|
-
#before_save :set_confirm_token
|
17
|
-
|
18
|
-
def password
|
19
|
-
@password ||= Password.new(encrypted_password)
|
20
|
-
end
|
21
|
-
|
22
|
-
def password= password
|
23
|
-
@password = password
|
24
|
-
end
|
25
|
-
|
26
|
-
def authenticate request
|
27
|
-
if self.password == request["password"]
|
28
|
-
true
|
29
|
-
else
|
30
|
-
false
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def remember_me!
|
35
|
-
self.update_attributes(:remember_token => new_token)
|
36
|
-
end
|
37
|
-
|
38
|
-
def forget_me!
|
39
|
-
self.update_attributes(:remember_token => nil)
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
def encrypt_password
|
44
|
-
self.encrypted_password = Password.create(@password)
|
45
|
-
end
|
46
|
-
|
47
|
-
def set_confirm_token
|
48
|
-
self.confirm_token = new_token
|
49
|
-
end
|
50
|
-
|
51
|
-
def new_token
|
52
|
-
Password.create(Time.new.to_s)
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
<%= flash[:error] %>
|
2
|
-
<%= flash[:notice] %>
|
3
|
-
<form action="login" method="post">
|
4
|
-
<p>Username:<input type="text" name="email" /></p>
|
5
|
-
<p>Password:<input type="password" name="password" /></p>
|
6
|
-
<p>Remember Me: <input type="radio" name="remember_me" /></p>
|
7
|
-
<p><input type="submit" name="Submit" /></p>
|
8
|
-
</form>
|
@@ -1,8 +0,0 @@
|
|
1
|
-
<%= flash[:error] %>
|
2
|
-
<%= flash[:notice] %>
|
3
|
-
<form action="signup" method="post">
|
4
|
-
<p>E-mail:<input type="text" name="email" /></p>
|
5
|
-
<p>Password:<input type="password" name="password" /></p>
|
6
|
-
<p>Confirm password:<input type="password" name="password_confirmation" /></p>
|
7
|
-
<input type="submit" value="Register!" />
|
8
|
-
</form>
|