honey-auth 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/sessions_controller.rb +1 -1
- data/app/views/sessions/new.html.haml +1 -1
- data/lib/generators/honey_auth/base.rb +9 -0
- data/lib/generators/honey_auth/init_generator.rb +19 -0
- data/lib/generators/honey_auth/templates/user_migration.rb +12 -0
- data/lib/generators/honey_auth/templates/user_model.rb +8 -0
- data/lib/honey_auth.rb +2 -1
- data/lib/honey_auth/roles.rb +10 -0
- metadata +19 -3
@@ -4,7 +4,7 @@ class SessionsController < ApplicationController
|
|
4
4
|
def create
|
5
5
|
if @user = User.find_by_email(params[:user][:email]).try(:authenticate, params[:user][:password])
|
6
6
|
sign_in @user
|
7
|
-
redirect_to signed_in_path
|
7
|
+
redirect_to signed_in_path(:signed_in)
|
8
8
|
else
|
9
9
|
@user = User.new
|
10
10
|
flash[:error] = 'bad email/password combination'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
%article.new-session-page
|
2
2
|
%h4 Sign in to your account
|
3
3
|
|
4
|
-
= form_for @
|
4
|
+
= form_for @user, url: session_path do |f|
|
5
5
|
= f.email :email, placeholder: 'Email'
|
6
6
|
= f.password :password, placeholder: 'Password', class: 'password'
|
7
7
|
= f.actions save: 'Sign in'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rails/generators/active_record/migration'
|
2
|
+
require 'generators/honey_auth/base'
|
3
|
+
|
4
|
+
module HoneyAuth
|
5
|
+
module Generators
|
6
|
+
|
7
|
+
class Init < Base
|
8
|
+
include Rails::Generators::Migration
|
9
|
+
extend ActiveRecord::Generators::Migration
|
10
|
+
source_root File.expand_path('../templates', __FILE__)
|
11
|
+
|
12
|
+
def create_migration_file
|
13
|
+
template 'user_model.rb', 'app/models/user.rb'
|
14
|
+
migration_template 'user_migration.rb', 'db/migrate/create_users'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class User < ActiveRecord::Base
|
2
|
+
has_secure_password
|
3
|
+
attr_accessible :email, :name, :password, :password_confirmation
|
4
|
+
validates :email, presence: true
|
5
|
+
validates_uniqueness_of :email, case_sensitive: false, allow_nil: true
|
6
|
+
ROLES = %w(user admin)
|
7
|
+
include HoneyAuth::Roles
|
8
|
+
end
|
data/lib/honey_auth.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: honey-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-10-16 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: haml
|
16
|
-
requirement: &
|
16
|
+
requirement: &70154157660380 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,18 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70154157660380
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: bcrypt-ruby
|
27
|
+
requirement: &70154157659900 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70154157659900
|
25
36
|
description: Very basic auth generator
|
26
37
|
email: q.shanahan@gmail.com
|
27
38
|
executables: []
|
@@ -29,8 +40,13 @@ extensions: []
|
|
29
40
|
extra_rdoc_files: []
|
30
41
|
files:
|
31
42
|
- lib/authentication.rb
|
43
|
+
- lib/generators/honey_auth/base.rb
|
44
|
+
- lib/generators/honey_auth/init_generator.rb
|
45
|
+
- lib/generators/honey_auth/templates/user_migration.rb
|
46
|
+
- lib/generators/honey_auth/templates/user_model.rb
|
32
47
|
- lib/honey-auth.rb
|
33
48
|
- lib/honey_auth/engine.rb
|
49
|
+
- lib/honey_auth/roles.rb
|
34
50
|
- lib/honey_auth/routes.rb
|
35
51
|
- lib/honey_auth.rb
|
36
52
|
- app/controllers/accounts_controller.rb
|