passwordless 0.4.3 → 0.4.4
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 +4 -4
- data/README.md +1 -1
- data/app/controllers/passwordless/sessions_controller.rb +1 -7
- data/lib/passwordless/controller_helpers.rb +14 -0
- data/lib/passwordless/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 307e6e1f46ccc9341e5ca07755b8c60cf5df9dfe7ce0827c2ff73e3b830d199b
|
4
|
+
data.tar.gz: eced1cc3a2b2abdce1194beb887f217bce6752a131152e1a8020987126030a49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c91e2385d7bfed3c083f3434426241052e0d0ca9566442c46d52e07ab107cb8dd70b5d81e5199ab56fb8ebba3dde6d47345a293be3dff40590f94b7290615d8
|
7
|
+
data.tar.gz: e43f2ec499c6b9df234956f0560bcad613489ee8e2175f5cb3f9fbba3d6583f842afb703ec8ca3138b651fb41f226ca20ca52ddbf805167c51995e0bfc74ed76
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
<br />
|
5
5
|
</p>
|
6
6
|
|
7
|
-
|
7
|
+
[](https://travis-ci.org/mikker/passwordless) [](https://rubygems.org/gems/passwordless) [](https://codecov.io/gh/mikker/passwordless)
|
8
8
|
|
9
9
|
Add authentication to your Rails app without all the icky-ness of passwords.
|
10
10
|
|
@@ -22,13 +22,7 @@ module Passwordless
|
|
22
22
|
# renders sessions/create.html.erb.
|
23
23
|
# @see Mailer#magic_link Mailer#magic_link
|
24
24
|
def create
|
25
|
-
|
26
|
-
|
27
|
-
session = Session.new.tap do |us|
|
28
|
-
us.remote_addr = request.remote_addr
|
29
|
-
us.user_agent = request.env['HTTP_USER_AGENT']
|
30
|
-
us.authenticatable = authenticatable
|
31
|
-
end
|
25
|
+
session = build_passwordless_session(find_authenticatable)
|
32
26
|
|
33
27
|
if session.save
|
34
28
|
Mailer.magic_link(session).deliver_now
|
@@ -3,6 +3,20 @@
|
|
3
3
|
module Passwordless
|
4
4
|
# Helpers to work with Passwordless sessions from controllers
|
5
5
|
module ControllerHelpers
|
6
|
+
# Build a new Passwordless::Session from an _authenticatable_ record.
|
7
|
+
# Set's `user_agent` and `remote_addr` from Rails' `request`.
|
8
|
+
# @param authenticatable [ActiveRecord::Base] Instance of an
|
9
|
+
# authenticatable Rails model
|
10
|
+
# @return [Session] the new Session object
|
11
|
+
# @see ModelHelpers#passwordless_with
|
12
|
+
def build_passwordless_session(authenticatable)
|
13
|
+
Session.new.tap do |us|
|
14
|
+
us.remote_addr = request.remote_addr
|
15
|
+
us.user_agent = request.env['HTTP_USER_AGENT']
|
16
|
+
us.authenticatable = authenticatable
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
6
20
|
# Authenticate a record using cookies. Looks for a cookie corresponding to
|
7
21
|
# the _authenticatable_class_. If found try to find it in the database.
|
8
22
|
# @param authenticatable_class [ActiveRecord::Base] any Model connected to
|
data/lib/passwordless/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: passwordless
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikkel Malmberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|