basic-initial-rails4 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,9 +12,9 @@ class SessionsController < ApplicationController
12
12
  $user = User.create(user_params)
13
13
  if $user.save
14
14
  session[:user_id] = $user.id
15
- redirect_to root_path
15
+ redirect_to root_path, notice: 'Sign in sussesfull'
16
16
  else
17
- redirect_to new_user_path
17
+ redirect_to new_user_path, notice: 'Problems creeting a user'
18
18
  end
19
19
  else
20
20
  request.env['omniauth.auth'].nil? ? (redirect_to new_user_path) : set_omniauth_user
@@ -1,5 +1,4 @@
1
1
  class UsersController < ApplicationController
2
- skip_before_action :is_login!, only: [:create, :new]
3
2
 
4
3
  def index
5
4
 
@@ -7,14 +6,12 @@ class UsersController < ApplicationController
7
6
 
8
7
  def create
9
8
  if params[:commit] === 'Sign in'
10
- user = User.find_by_email(params[:user][:email])
11
- if user and user.authenticate(params[:user][:password])
12
- session[:user_id] = user.id
13
- flash[:notice] = 'Signed in successfully'
14
- redirect_to root_path
9
+ $user = User.find_by_email(params[:user][:email])
10
+ if $user and user.authenticate(params[:user][:password])
11
+ session[:user_id] = $user.id
12
+ redirect_to root_path, notice: 'Sign in successfully'
15
13
  else
16
- $user = user
17
- redirect_to new_user_path
14
+ redirect_to sessions_new_path, notice: 'User or password error'
18
15
  end
19
16
  else
20
17
  redirect_to sessions_new_path
File without changes
@@ -1,3 +1,5 @@
1
+ .session-message
2
+ = flash[:notice] unless flash[:notice].nil?
1
3
  - if session[:user_id].nil?
2
4
  = link_to 'Twitter', '/auth/twitter' unless @init_twitter.nil?
3
5
  = link_to 'Github', '/auth/github' unless @init_github.nil?
@@ -1,3 +1,8 @@
1
+ .session-message
2
+ - @user.errors.full_messages.each do |message|
3
+ #{message}
4
+ %br
5
+ = flash[:notice] unless flash[:notice].nil?
1
6
  %h1 Sign up
2
7
  %p put information to complete your register
3
8
  = form_tag sessions_new_path, method: "POST" do |f|
@@ -1,7 +1,7 @@
1
1
  module Basic
2
2
  module Initial
3
3
  module Rails4
4
- VERSION = "1.1.0"
4
+ VERSION = "1.1.1"
5
5
  end
6
6
  end
7
7
  end
@@ -2,7 +2,7 @@ require 'rails/generators'
2
2
 
3
3
  class BinstallGenerator < Rails::Generators::Base
4
4
  source_root File.expand_path('../templates', __FILE__)
5
- desc 'This generator copy an initializer file at config/initializers/omniauth.rb'
5
+ desc 'This generator prepared the rails app to load action perfecty and config the gem expecial parameters'
6
6
  def copy_initializers_files
7
7
  initial_route = 'config/initializers/'
8
8
  copy_file "#{initial_route}mail.rb", "#{initial_route}mail.rb"
@@ -27,7 +27,7 @@ class BinstallGenerator < Rails::Generators::Base
27
27
 
28
28
  def load_login_method
29
29
  inject_into_file 'app/helpers/application_helper.rb', after: 'module ApplicationHelper' do
30
- "\n def is_login!\n
30
+ "\n def is_login!
31
31
  if session[:user_id].nil?
32
32
  redirect_to sessions_new_path, notice: 'You need login to load this section'
33
33
  elsif $current_user.nil?
@@ -39,7 +39,7 @@ class BinstallGenerator < Rails::Generators::Base
39
39
 
40
40
  def load_initial_link_ban
41
41
  inject_into_file 'app/controllers/application_controller.rb', after: 'protect_from_forgery with: :exception' do
42
- "\n before_filter :load_initial
42
+ "\n before_filter :load_initial\n
43
43
  def load_initial
44
44
  @init_twitter = nil
45
45
  @init_github = nil
@@ -54,7 +54,6 @@ class BinstallGenerator < Rails::Generators::Base
54
54
  "\n get 'sessions/new'
55
55
  post 'sessions/new', to: 'sessions#create'
56
56
  get 'sessions/destroy', to: 'sessions#logout'
57
- root to: 'users#index'
58
57
  resources :users, only: [:index, :create, :new]
59
58
  get '/auth/:provider/callback', to: 'sessions#create'
60
59
  get '/auth/failure', to: 'sessions#failure'"
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.0
4
+ version: 1.1.1
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-01 00:00:00.000000000 Z
12
+ date: 2013-10-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -185,13 +185,12 @@ files:
185
185
  - LICENSE.txt
186
186
  - README.md
187
187
  - Rakefile
188
- - app/controllers/session_user.rb
189
188
  - app/controllers/sessions_controller.rb
190
189
  - app/controllers/users_controller.rb
191
190
  - app/models/.keep
191
+ - app/models/session_user.rb
192
192
  - app/models/user.rb
193
193
  - app/views/sessions/new.html.haml
194
- - app/views/users/index.html.haml
195
194
  - app/views/users/new.html.haml
196
195
  - basic-initial-rails4.gemspec
197
196
  - lib/basic/initial/rails4.rb
@@ -1 +0,0 @@
1
- %h1 jols