basic-initial-rails4 1.1.2 → 1.1.3
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.
@@ -8,16 +8,18 @@ class SessionsController < ApplicationController
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def create
|
11
|
-
if params[:commit] === 'Sign
|
12
|
-
$user = User.
|
13
|
-
if $user.
|
11
|
+
if params[:commit] === 'Sign in'
|
12
|
+
$user = User.find_by_email(params[:email])
|
13
|
+
if $user and $user.authenticate(params[:password])
|
14
14
|
session[:user_id] = $user.id
|
15
|
-
redirect_to root_path,
|
15
|
+
redirect_to root_path,
|
16
|
+
notice: 'Sign in successfully'
|
16
17
|
else
|
17
|
-
redirect_to
|
18
|
+
redirect_to sessions_new_path,
|
19
|
+
notice: 'User or password error'
|
18
20
|
end
|
19
21
|
else
|
20
|
-
|
22
|
+
request.env['omniauth'].nil? ? (redirect_to sessions_new_path) : set_omniauth_user
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
@@ -29,7 +31,7 @@ class SessionsController < ApplicationController
|
|
29
31
|
|
30
32
|
def failure
|
31
33
|
end
|
32
|
-
|
34
|
+
|
33
35
|
private
|
34
36
|
|
35
37
|
def set_omniauth_user
|
@@ -46,8 +48,4 @@ class SessionsController < ApplicationController
|
|
46
48
|
end
|
47
49
|
redirect_to root_path
|
48
50
|
end
|
49
|
-
|
50
|
-
def user_params
|
51
|
-
params.permit(:name, :email, :password, :password_confirmation)
|
52
|
-
end
|
53
51
|
end
|
@@ -5,18 +5,18 @@ class UsersController < ApplicationController
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def create
|
8
|
-
if params[:commit] === 'Sign
|
9
|
-
$user = User.
|
10
|
-
if $user
|
8
|
+
if params[:commit] === 'Sign up'
|
9
|
+
$user = User.create(user_params)
|
10
|
+
if $user.save
|
11
11
|
session[:user_id] = $user.id
|
12
12
|
redirect_to root_path,
|
13
|
-
notice: 'Sign in
|
13
|
+
notice: 'Sign in successfull'
|
14
14
|
else
|
15
|
-
redirect_to
|
16
|
-
notice: '
|
15
|
+
redirect_to new_user_path,
|
16
|
+
notice: 'Problems creeting a user'
|
17
17
|
end
|
18
18
|
else
|
19
|
-
redirect_to
|
19
|
+
redirect_to new_user_path
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -25,4 +25,8 @@ class UsersController < ApplicationController
|
|
25
25
|
@user = $user unless $user.nil?
|
26
26
|
$user = nil
|
27
27
|
end
|
28
|
+
|
29
|
+
def user_params
|
30
|
+
params.permit(:name, :email, :password, :password_confirmation)
|
31
|
+
end
|
28
32
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
.session-message
|
2
|
-
|
2
|
+
- unless flash[:notice].nil?
|
3
|
+
%br
|
4
|
+
= flash[:notice]
|
3
5
|
- if session[:user_id].nil?
|
4
6
|
= link_to 'Twitter', '/auth/twitter' unless @init_twitter.nil?
|
5
7
|
= link_to 'Github', '/auth/github' unless @init_github.nil?
|
@@ -7,7 +9,7 @@
|
|
7
9
|
= link_to 'Linked_in', '/auth/linked_in' unless @init_linkedin.nil?
|
8
10
|
%h1 Sign in
|
9
11
|
%p Put you information to login
|
10
|
-
= form_tag
|
12
|
+
= form_tag sessions_new_path, method: 'POST' do |f|
|
11
13
|
%table{width: '25%'}
|
12
14
|
%tr
|
13
15
|
%td
|
@@ -3,10 +3,12 @@
|
|
3
3
|
- @user.errors.full_messages.each do |message|
|
4
4
|
#{message}
|
5
5
|
%br
|
6
|
-
|
6
|
+
- unless flash[:notice].nil?
|
7
|
+
%br
|
8
|
+
= flash[:notice]
|
7
9
|
%h1 Sign up
|
8
10
|
%p put information to complete your register
|
9
|
-
= form_tag
|
11
|
+
= form_tag users_path, method: "POST" do |f|
|
10
12
|
%table{width: "25%"}
|
11
13
|
%tr
|
12
14
|
%td
|
@@ -27,6 +27,6 @@ Gem::Specification.new do |gem|
|
|
27
27
|
gem.add_development_dependency "haml-rails", ">= 0.3"
|
28
28
|
gem.add_development_dependency "omniauth-twitter", ">= 1.0.0"
|
29
29
|
gem.add_development_dependency 'bcrypt-ruby', '~> 3.0.0'
|
30
|
-
gem.add_development_dependency "bootstrap-
|
30
|
+
gem.add_development_dependency "bootstrap-v3-rails"
|
31
31
|
gem.add_development_dependency "rake"
|
32
32
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: basic-initial-rails4
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -140,7 +140,7 @@ dependencies:
|
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: 3.0.0
|
142
142
|
- !ruby/object:Gem::Dependency
|
143
|
-
name: bootstrap-
|
143
|
+
name: bootstrap-v3-rails
|
144
144
|
requirement: !ruby/object:Gem::Requirement
|
145
145
|
none: false
|
146
146
|
requirements:
|