basic-initial-rails4 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ class SessionsController < ApplicationController
3
3
 
4
4
  def new
5
5
  redirect_to root_path unless session[:user_id].nil?
6
- $user.nil? ? @user = User.new : @user = $user
6
+ @user = $user unless $user.nil?
7
7
  $user = nil
8
8
  end
9
9
 
@@ -6,12 +6,14 @@ class UsersController < ApplicationController
6
6
 
7
7
  def create
8
8
  if params[:commit] === 'Sign in'
9
- $user = User.find_by_email(params[:user][:email])
10
- if $user and user.authenticate(params[:user][:password])
9
+ $user = User.find_by_email(params[:email])
10
+ if $user and $user.authenticate(params[:password])
11
11
  session[:user_id] = $user.id
12
- redirect_to root_path, notice: 'Sign in successfully'
12
+ redirect_to root_path,
13
+ notice: 'Sign in successfully'
13
14
  else
14
- redirect_to sessions_new_path, notice: 'User or password error'
15
+ redirect_to sessions_new_path,
16
+ notice: 'User or password error'
15
17
  end
16
18
  else
17
19
  redirect_to sessions_new_path
@@ -20,7 +22,7 @@ class UsersController < ApplicationController
20
22
 
21
23
  def new
22
24
  redirect_to root_path unless session[:user_id].nil?
23
- $user.nil? ? @user = User.new : @user = $user
25
+ @user = $user unless $user.nil?
24
26
  $user = nil
25
27
  end
26
28
  end
@@ -7,25 +7,25 @@
7
7
  = link_to 'Linked_in', '/auth/linked_in' unless @init_linkedin.nil?
8
8
  %h1 Sign in
9
9
  %p Put you information to login
10
- = form_for @user do |f|
10
+ = form_tag users_path, method: 'POST' do |f|
11
11
  %table{width: '25%'}
12
12
  %tr
13
13
  %td
14
- = f.label :email, 'You user email'
14
+ = label_tag :email, 'You user email'
15
15
  %td
16
- = f.text_field :email
16
+ = text_field_tag :email
17
17
  %tr
18
18
  %td
19
- = f.label :password
19
+ = label_tag :password, 'Password'
20
20
  %td
21
- = f.password_field :password
21
+ = password_field_tag :password
22
22
  %tr
23
23
  %td
24
- = f.label :password_confirmation
24
+ = label_tag :password_confirmation, 'Password Confirmation'
25
25
  %td
26
- = f.password_field :password_confirmation
26
+ = password_field_tag :password_confirmation
27
27
  %tr
28
28
  %td
29
- = f.submit 'Sign in'
29
+ = submit_tag 'Sign in'
30
30
  %td
31
- = f.submit 'Cancel'
31
+ = submit_tag 'Cancel'
@@ -1,6 +1,7 @@
1
1
  .session-message
2
- - @user.errors.full_messages.each do |message|
3
- #{message}
2
+ - unless @user.nil?
3
+ - @user.errors.full_messages.each do |message|
4
+ #{message}
4
5
  %br
5
6
  = flash[:notice] unless flash[:notice].nil?
6
7
  %h1 Sign up
@@ -1,7 +1,7 @@
1
1
  module Basic
2
2
  module Initial
3
3
  module Rails4
4
- VERSION = "1.1.1"
4
+ VERSION = "1.1.2"
5
5
  end
6
6
  end
7
7
  end
@@ -25,19 +25,7 @@ class BinstallGenerator < Rails::Generators::Base
25
25
  create_file 'app/notifier/mail_method.html.rb'
26
26
  end
27
27
 
28
- def load_login_method
29
- inject_into_file 'app/helpers/application_helper.rb', after: 'module ApplicationHelper' do
30
- "\n def is_login!
31
- if session[:user_id].nil?
32
- redirect_to sessions_new_path, notice: 'You need login to load this section'
33
- elsif $current_user.nil?
34
- $current_user = User.find_by_id(session[:user_id])
35
- end
36
- end"
37
- end
38
- end
39
-
40
- def load_initial_link_ban
28
+ def load_initial_necessary
41
29
  inject_into_file 'app/controllers/application_controller.rb', after: 'protect_from_forgery with: :exception' do
42
30
  "\n before_filter :load_initial\n
43
31
  def load_initial
@@ -45,6 +33,13 @@ class BinstallGenerator < Rails::Generators::Base
45
33
  @init_github = nil
46
34
  @init_facebook = nil
47
35
  @init_linkedin = nil
36
+ end\n
37
+ def is_login!
38
+ if session[:user_id].nil?
39
+ redirect_to sessions_new_path, notice: 'You need login to load this section'
40
+ elsif $current_user.nil?
41
+ $current_user = User.find_by_id(session[:user_id])
42
+ end
48
43
  end"
49
44
  end
50
45
  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.1
4
+ version: 1.1.2
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-03 00:00:00.000000000 Z
12
+ date: 2013-10-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails