minnie 0.0.2 → 0.0.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.
data/README.md CHANGED
@@ -2,67 +2,23 @@
2
2
 
3
3
  ###Install
4
4
 
5
- Add minnie and bcrypt-ruby to your Gemfile
5
+ Add minnie to your Gemfile
6
6
 
7
7
  gem 'minnie'
8
- gem 'bcrypt-ruby'
9
8
 
10
- Include minnie's authentication in application_controller.rb and set it to require
11
- authentication for every controller
9
+ Run minnie's generator to get up and running
12
10
 
13
- class ApplicationController
14
- include Minnie::Authentication
11
+ bundle exec rails generate minnie:install
15
12
 
16
- before_filter :authenticate_user!
17
-
18
- ...
13
+ You're all done! Log into the console and create a test user
19
14
 
20
- Create a sessions_controller.rb
15
+ User.create :email => 'test@test.com', :password => 'test'
21
16
 
22
- class SessionsController < ApplicationController
23
- skip_before_filter :authenticate_user!, :except => [:destroy]
17
+ And then try to sign in to your app at [/signin](http://localhost:3000/signin).
24
18
 
25
- def new
26
- @user = User.new
27
- end
19
+ ###Issues
28
20
 
29
- def create
30
- if @user = authenticate(params[:user][:email], params[:user][:password])
31
- sign_in_and_redirect(@user)
32
- else
33
- flash.now[:error] = I18n.t(:invalid_login, :scope => 'app.sessions')
34
- render "new"
35
- end
36
- end
21
+ There isn't much code here so try resolving issues on your own. If you get some issues fixed, send me a pull request!
37
22
 
38
- def destroy
39
- sign_out_and_redirect
40
- end
41
- end
42
-
43
- And a login form at app/views/sessions/new.html.erb (this one uses simple_form)
44
-
45
- <h2>Sign in</h2>
46
-
47
- <%= simple_form_for @user, :url => sessions_path do |f| %>
48
- <%= f.error_notification %>
49
-
50
- <div class="inputs">
51
- <%= f.input :email %>
52
- <%= f.input :password %>
53
- </div>
54
- <div class="actions">
55
- <%= f.button :submit, 'Sign In' %>
56
- </div>
57
- <% end %>
58
-
59
- Generate a user.rb that is set up for has_secure_password
60
-
61
- bundle exec rails g model user email:string password_digest:string
62
-
63
- And then update app/models/user.rb to include has_secure_password
64
-
65
- class User < ActiveRecord::Base
66
- has_secure_password
67
- end
23
+ If you're not making any headway, just create an issue and I'll try to look at it.
68
24
 
@@ -0,0 +1,42 @@
1
+ module Minnie
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ source_root File.expand_path('../templates', __FILE__)
6
+ desc "Configures your app with the basics for Minnie to execute."
7
+
8
+ def install
9
+ inject_into_class "app/controllers/application_controller.rb", ApplicationController do
10
+ " include Minnie::Authentication\n\n before_filter :authenticate_user!\n"
11
+ end
12
+ end
13
+
14
+ def copy_sessions_controller
15
+ copy_file "sessions_controller.rb", "app/controllers/sessions_controller.rb"
16
+ end
17
+
18
+ def copy_session_form
19
+ copy_file "sessions/new.html.erb", "app/views/sessions/new.html.erb"
20
+ end
21
+
22
+ def copy_locale
23
+ copy_file "en.yml", "config/locales/minnie.en.yml"
24
+ end
25
+
26
+ def add_session_routes
27
+ route "resources :sessions, :only => [:new, :create, :destroy]"
28
+ route "match '/signin' => 'sessions#new', :as => :signin"
29
+ route "match '/signout' => 'sessions#destroy', :as => :signout"
30
+ end
31
+
32
+ def update_user
33
+ unless File.exists?('app/models/user.rb')
34
+ generate("model", "user email:string password_digest:string")
35
+ end
36
+ inject_into_class 'app/models/user.rb', User do
37
+ " has_secure_password\n\n attr_accessible :email, :password\n validates_presence_of :email\n validates_presence_of :password, :on => :create\n\n"
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,6 @@
1
+ en:
2
+ app:
3
+ sessions:
4
+ signed_in: 'Signed in successfully.'
5
+ signed_out: 'Signed out successfully.'
6
+ invalid_login: 'Invalid email or password.'
@@ -0,0 +1,13 @@
1
+ <h2>Sign in</h2>
2
+
3
+ <%= simple_form_for @user, :url => sessions_path do |f| %>
4
+ <%= f.error_notification %>
5
+
6
+ <div class="inputs">
7
+ <%= f.input :email %>
8
+ <%= f.input :password %>
9
+ </div>
10
+ <div class="actions">
11
+ <%= f.button :submit, 'Sign In' %>
12
+ </div>
13
+ <% end %>
@@ -1,3 +1,3 @@
1
1
  module Minnie
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/minnie.gemspec CHANGED
@@ -18,5 +18,6 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.add_runtime_dependency('rails', '>= 3.0')
21
+ s.add_dependency("bcrypt-ruby", "~> 3.0")
22
+ s.add_dependency("railties", "~> 3.0")
22
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minnie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,16 +12,27 @@ cert_chain: []
12
12
  date: 2012-02-21 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rails
16
- requirement: &70109536609320 !ruby/object:Gem::Requirement
15
+ name: bcrypt-ruby
16
+ requirement: &70298217510040 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - ~>
20
20
  - !ruby/object:Gem::Version
21
21
  version: '3.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70109536609320
24
+ version_requirements: *70298217510040
25
+ - !ruby/object:Gem::Dependency
26
+ name: railties
27
+ requirement: &70298217509520 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '3.0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70298217509520
25
36
  description: The simplest that authentication can get while still being useful
26
37
  email:
27
38
  - mike@sideline.ca
@@ -33,7 +44,10 @@ files:
33
44
  - Gemfile
34
45
  - README.md
35
46
  - Rakefile
36
- - lib/generators/templates/sessions_controller.rb
47
+ - lib/generators/minnie/install_generator.rb
48
+ - lib/generators/minnie/templates/en.yml
49
+ - lib/generators/minnie/templates/sessions/new.html.erb
50
+ - lib/generators/minnie/templates/sessions_controller.rb
37
51
  - lib/minnie.rb
38
52
  - lib/minnie/authentication.rb
39
53
  - lib/minnie/version.rb
@@ -52,7 +66,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
52
66
  version: '0'
53
67
  segments:
54
68
  - 0
55
- hash: 3873794554763273120
69
+ hash: 1966131099083453322
56
70
  required_rubygems_version: !ruby/object:Gem::Requirement
57
71
  none: false
58
72
  requirements:
@@ -61,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
75
  version: '0'
62
76
  segments:
63
77
  - 0
64
- hash: 3873794554763273120
78
+ hash: 1966131099083453322
65
79
  requirements: []
66
80
  rubyforge_project: minnie
67
81
  rubygems_version: 1.8.7