easy_login 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 94986a40bef59cb4c5e8bf3549b5d5df441c1389
4
+ data.tar.gz: ea29109d1a6167b54f73fd2f108c6ebe74be6ed0
5
+ SHA512:
6
+ metadata.gz: 8e1698b438bdbce6e297dc44de1f786de8b322da1a587d91bbd73f2c63f903b533207fe0b52cdc2f6c400459513a07e4243ea0b1a928407531704e25684c79c4
7
+ data.tar.gz: bf210f342d53ea50b4b2f1177f966c60b7872a6e1830a56b012da24c51b08d4988bfbcafc25b9312d106702cd9cd2f7dc3b5dd6f3463850e1520cc705ed21c93
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in easy_login.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 goshan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # EasyLogin
2
+
3
+ a simple session controller which just including
4
+
5
+ + :sign_in
6
+ + :sign_out
7
+ + :sign_in?
8
+ + :current_user
9
+ + :current_user?
10
+
11
+ for controllers and
12
+
13
+ + :current_user
14
+ + :current_user?
15
+ + :sign_in?
16
+
17
+ for views
18
+
19
+ ## Installation
20
+
21
+ Add this line to your application's Gemfile:
22
+
23
+ ```ruby
24
+ gem 'easy_login'
25
+ ```
26
+
27
+ And then execute:
28
+
29
+ $ bundle
30
+
31
+ Or install it yourself as:
32
+
33
+ $ gem install easy_login
34
+
35
+ ## Usage
36
+
37
+ Add following code into `app/controllers/application_controller.rb`
38
+
39
+ ```ruby
40
+ class ApplicationController < ActionController::Base
41
+ include EasyLogin::Session
42
+ helper_method EasyLogin.helper_method
43
+ end
44
+ ```
45
+
46
+ And then you can use all the methods above in controller and view
47
+
48
+ ## Contributing
49
+
50
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/easy_login. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
51
+
52
+
53
+ ## License
54
+
55
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
56
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'easy_login/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "easy_login"
8
+ spec.version = EasyLogin::VERSION
9
+ spec.authors = ["goshan"]
10
+ spec.email = ["goshan.hanqiu@dena.jp"]
11
+
12
+ spec.summary = %q{a simple user session controling tool for rails}
13
+ spec.description = %q{a simple session controller which just including :sign_in, :sign_out, :sign_in?, :current_user, :current_user? for controllers and :current_user, :current_user?, :sign_in? for views}
14
+ spec.homepage = "https://github.com/goshan/easy_login"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.10"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ end
@@ -0,0 +1,35 @@
1
+ module EasyLogin
2
+ module Session
3
+ def signed_in?
4
+ return !current_user.nil?
5
+ end
6
+
7
+ def current_user?(user)
8
+ if(user == nil || current_user == nil)
9
+ return false;
10
+ end
11
+ return user.id == current_user.id
12
+ end
13
+
14
+ def sign_in(user)
15
+ cookies.permanent.signed[:remember_token] = [user.id, "TODO_salt"]
16
+ end
17
+
18
+ def sign_out
19
+ cookies.delete(:remember_token)
20
+ end
21
+
22
+ def current_user
23
+ user_from_remember_token
24
+ end
25
+
26
+ private
27
+ def user_from_remember_token
28
+ User.auth_with_salt(remember_token[0])
29
+ end
30
+
31
+ def remember_token
32
+ cookies.signed[:remember_token] || [nil, nil]
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,3 @@
1
+ module EasyLogin
2
+ VERSION = "0.1.0"
3
+ end
data/lib/easy_login.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "easy_login/version"
2
+ require "easy_login/session"
3
+
4
+ module EasyLogin
5
+ def self.helper_method
6
+ [:sign_in?, :current_user, :current_user?]
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: easy_login
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - goshan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: a simple session controller which just including :sign_in, :sign_out,
42
+ :sign_in?, :current_user, :current_user? for controllers and :current_user, :current_user?,
43
+ :sign_in? for views
44
+ email:
45
+ - goshan.hanqiu@dena.jp
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".gitignore"
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - easy_login.gemspec
56
+ - lib/easy_login.rb
57
+ - lib/easy_login/session.rb
58
+ - lib/easy_login/version.rb
59
+ homepage: https://github.com/goshan/easy_login
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.4.5
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: a simple user session controling tool for rails
83
+ test_files: []