monban 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aca082188020521eb26286f4329290137e03ee38
4
- data.tar.gz: 9bfb518930ce8de955f38ebd44371645e1051324
3
+ metadata.gz: 5ddc7a11787b21de324a81083cebd5fe124ad2c6
4
+ data.tar.gz: aa811bccba901006fe74a899b4680fb7c00fe1f2
5
5
  SHA512:
6
- metadata.gz: 0e43239016ff07761fc2b870276033cbad7b16f4bb8dac62555f1bb5328be648d2ec74ec69c622d6ecec46bc8f9bbcc724f758b4f518ba10cafda1212bf6b3db
7
- data.tar.gz: bccdc6fe8918d5b4ee34a9127fa591bb28617ff2b1cb786fe4ca8926746b72aa2800f73dd979d18677e4f96328a6145f41becccde90253266babf00760869db1
6
+ metadata.gz: 1d9b4249d74884590f3a1b149203ddb64aae28d6cd1808b06867f6d93d1dd06feb8eb08d00ab02e71bf0aeb1b1e2dccc20b9767bfdeacd103d5610b8ae6e7003
7
+ data.tar.gz: 8e6a67a72c5b208eaade600c371f561f01f49b317b859978ddd766e9357fdf54760727fcbfb57e25f801542857c0b79b96dc7a8ee880891e00fb028f1edd40c3
data/README.md CHANGED
@@ -35,17 +35,9 @@ Then inside of your ApplicationController add the following:
35
35
 
36
36
  And you're ready to start designing your authentication system.
37
37
 
38
- ## Scaffold
38
+ ## Generators
39
39
 
40
- If you don't want to add all the components yourself, you may instead generate
41
- a scaffold to start with by running:
42
-
43
- rails g monban:scaffold
44
-
45
- This will generate a bare bones starting point. If you don't want the full
46
- stack you can just generate some controllers with:
47
-
48
- rails g monban:controllers
40
+ If you'd like a good starting point for building an app using Monban, it is suggested to use the [monban generators](https://github.com/halogenandtoast/monban-generators).
49
41
 
50
42
  ## Usage
51
43
 
@@ -169,10 +161,12 @@ You may perform a look up on a user using multiple fields by doing something lik
169
161
  class SessionsController < ApplicationController
170
162
  def create
171
163
  user = authenticate_session(session_params, email_or_username: [:email, :username])
172
- sign_in(user) do
173
- redirect_to(root_path) and return
164
+
165
+ if sign_in(user)
166
+ redirect_to(root_path)
167
+ else
168
+ render :new
174
169
  end
175
- render :new
176
170
  end
177
171
 
178
172
  private
@@ -1,3 +1,3 @@
1
1
  module Monban
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.13"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monban
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - halogenandtoast
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-01 00:00:00.000000000 Z
12
+ date: 2014-05-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -151,13 +151,6 @@ files:
151
151
  - LICENSE.txt
152
152
  - README.md
153
153
  - Rakefile
154
- - lib/generators/monban/controllers/controllers_generator.rb
155
- - lib/generators/monban/scaffold/scaffold_generator.rb
156
- - lib/generators/monban/templates/app/controllers/sessions_controller.rb
157
- - lib/generators/monban/templates/app/controllers/users_controller.rb
158
- - lib/generators/monban/templates/app/views/sessions/new.html.erb
159
- - lib/generators/monban/templates/app/views/users/new.html.erb
160
- - lib/generators/monban/templates/scaffold_readme
161
154
  - lib/monban.rb
162
155
  - lib/monban/back_door.rb
163
156
  - lib/monban/configuration.rb
@@ -1,38 +0,0 @@
1
- require 'rails/generators/base'
2
-
3
- module Monban
4
- module Generators
5
- class ControllersGenerator < Rails::Generators::Base
6
- source_root File.expand_path("../../templates", __FILE__)
7
-
8
- def copy_controllers
9
- template 'app/controllers/sessions_controller.rb', 'app/controllers/sessions_controller.rb', config
10
- template 'app/controllers/users_controller.rb', 'app/controllers/users_controller.rb', config
11
- end
12
-
13
- private
14
-
15
- def config
16
- @_config ||= {
17
- use_strong_parameters: using_strong_parameters
18
- }
19
- end
20
-
21
- def using_strong_parameters
22
- if rails4? || strong_parameters_gem?
23
- true
24
- else
25
- yes?("Using strong_parameters?")
26
- end
27
- end
28
-
29
- def strong_parameters_gem?
30
- Kernel.const_defined?("StrongParameters")
31
- end
32
-
33
- def rails4?
34
- Rails::VERSION::MAJOR == 4
35
- end
36
- end
37
- end
38
- end
@@ -1,37 +0,0 @@
1
- require 'rails/generators/active_record'
2
- require 'generators/monban/controllers/controllers_generator'
3
-
4
- module Monban
5
- module Generators
6
- class ScaffoldGenerator < ControllersGenerator
7
- include Rails::Generators::Migration
8
- source_root File.expand_path("../../templates", __FILE__)
9
-
10
- def add_routes
11
- route("resources :users, only: [:new, :create]")
12
- route("resource :session, only: [:new, :create, :destroy]")
13
- end
14
-
15
- def add_views
16
- copy_file 'app/views/users/new.html.erb'
17
- copy_file 'app/views/sessions/new.html.erb'
18
- end
19
-
20
- def add_helper_module_to_application_controller
21
- inject_into_class "app/controllers/application_controller.rb", ApplicationController, " include Monban::ControllerHelpers\n"
22
- end
23
-
24
- def self.next_migration_number(dir)
25
- ActiveRecord::Generators::Base.next_migration_number(dir)
26
- end
27
-
28
- def add_model
29
- generate 'model', 'user email password_digest'
30
- end
31
-
32
- def display_readme
33
- readme 'scaffold_readme'
34
- end
35
- end
36
- end
37
- end
@@ -1,30 +0,0 @@
1
- class SessionsController < ApplicationController
2
- def new
3
- end
4
-
5
- def create
6
- user = authenticate_session(session_params)
7
-
8
- if sign_in(user)
9
- redirect_to root_path
10
- else
11
- render :new
12
- end
13
- end
14
-
15
- def destroy
16
- sign_out
17
- redirect_to root_path
18
- end
19
-
20
- private
21
-
22
- def session_params
23
- <% if config[:use_strong_parameters] -%>
24
- params.require(:session).permit(:email, :password)
25
- <% else -%>
26
- params[:session]
27
- <% end -%>
28
- end
29
- end
30
-
@@ -1,27 +0,0 @@
1
- class UsersController < ApplicationController
2
- def new
3
- @user = User.new
4
- end
5
-
6
- def create
7
- @user = sign_up(user_params)
8
-
9
- if @user.valid?
10
- sign_in(@user)
11
- redirect_to root_path
12
- else
13
- render :new
14
- end
15
- end
16
-
17
- private
18
-
19
- def user_params
20
- <% if config[:use_strong_parameters] -%>
21
- params.require(:user).permit(:email, :password)
22
- <% else -%>
23
- params[:user]
24
- <% end -%>
25
- end
26
- end
27
-
@@ -1,13 +0,0 @@
1
- <%= form_for :session, url: session_path do |form| %>
2
- <div>
3
- <%= form.label :email %>
4
- <%= form.email_field :email %>
5
- </div>
6
- <div>
7
- <%= form.label :password %>
8
- <%= form.password_field :password %>
9
- </div>
10
- <div>
11
- <%= form.submit "Sign in" %>
12
- </div>
13
- <% end %>
@@ -1,13 +0,0 @@
1
- <%= form_for @user do |form| %>
2
- <div>
3
- <%= form.label :email %>
4
- <%= form.email_field :email %>
5
- </div>
6
- <div>
7
- <%= form.label :password %>
8
- <%= form.password_field :password %>
9
- </div>
10
- <div>
11
- <%= form.submit "Sign up" %>
12
- </div>
13
- <% end %>
@@ -1,4 +0,0 @@
1
-
2
- Final Steps
3
- run:
4
- rake db:migrate