passwordless 0.4.3 → 0.4.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
  SHA256:
3
- metadata.gz: a3dbc0b122174ab4d4f115f47ef829bfe0ccfdf49cb559725e8833d5abaef517
4
- data.tar.gz: ba545dc28ee08852e3c2caf2c9d920343aac14d2039bd3dc4f48e399d99c8bf4
3
+ metadata.gz: 307e6e1f46ccc9341e5ca07755b8c60cf5df9dfe7ce0827c2ff73e3b830d199b
4
+ data.tar.gz: eced1cc3a2b2abdce1194beb887f217bce6752a131152e1a8020987126030a49
5
5
  SHA512:
6
- metadata.gz: 79e1c14bcc3d71e438f0f7b146642460d3116a3d681a2deb17bc6e860d819b990e68565de94a72caa640fa5958fc9587769b6ee0c6af7b16a2e3bac2475d6605
7
- data.tar.gz: 1695fc3178204892a35ee1a35869836b09d26005f4b4e4c99d2e9d02c813a87a1fefad6f00664302f191ecb4f3e3fe9cc57888aeadf2b8a7c6355fb1f1581873
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
- <img src='https://travis-ci.org/mikker/passwordless.svg?branch=master' alt='Build status' /> <img src='https://img.shields.io/gem/v/passwordless.svg' alt='Gem version' />
7
+ [![Travis](https://travis-ci.org/mikker/passwordless.svg?branch=master)](https://travis-ci.org/mikker/passwordless) [![Rubygems](https://img.shields.io/gem/v/passwordless.svg)](https://rubygems.org/gems/passwordless) [![codecov](https://codecov.io/gh/mikker/passwordless/branch/master/graph/badge.svg)](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
- authenticatable = find_authenticatable
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Passwordless
4
- VERSION = '0.4.3' # :nodoc:
4
+ VERSION = '0.4.4' # :nodoc:
5
5
  end
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.3
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: 2017-12-27 00:00:00.000000000 Z
11
+ date: 2018-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails