simple_login 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/simple_login/version.rb +1 -1
- data/lib/simple_login.rb +2 -52
- metadata +1 -1
data/lib/simple_login/version.rb
CHANGED
data/lib/simple_login.rb
CHANGED
@@ -2,55 +2,5 @@ require "simple_login/version"
|
|
2
2
|
require 'rails/generators/base'
|
3
3
|
|
4
4
|
module SimpleLogin
|
5
|
-
|
6
|
-
|
7
|
-
source_root File.expand_path('../templates', __FILE__)
|
8
|
-
|
9
|
-
def generate_user
|
10
|
-
# Copy the controllers for user, sessions and password_reset
|
11
|
-
directory "controllers", "app/controllers/"
|
12
|
-
directory "mailers", "app/mailers/"
|
13
|
-
directory "models", "app/models/"
|
14
|
-
directory "views", "app/views/"
|
15
|
-
end
|
16
|
-
|
17
|
-
def insert_general_methods
|
18
|
-
inject_into_file "app/controllers/application_controller.rb", after: "protect_from_forgery" do
|
19
|
-
a = "\n\n private\n\n def current_user\n"
|
20
|
-
b = " @current_user ||= User.find_by_auth_token!(cookies[:auth_token]) if cookies[:auth_token]\n"
|
21
|
-
c = " end\n"
|
22
|
-
d = "\n helper_method :current_user\n\n"
|
23
|
-
e = " def authorize\n"
|
24
|
-
f = " redirect_to login_url, alert: 'Not authorized. Please login.' if current_user.nil?\n"
|
25
|
-
g = " end\n"
|
26
|
-
a+b+c+d+e+f+g
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def insert_routes
|
31
|
-
insert_into_file "config/routes.rb", after: "Application.routes.draw do" do
|
32
|
-
a = "\n\nmatch 'signup', to: 'users#new', as: 'signup'\n"
|
33
|
-
b = "match 'login', to: 'sessions#new', as: 'login'\n"
|
34
|
-
c = "match 'logout', to: 'sessions#destroy', as: 'logout'\n"
|
35
|
-
d = "resources :users\n"
|
36
|
-
e = "resources :sessions\n"
|
37
|
-
f = "resources :password_resets\n"
|
38
|
-
a+b+c+d+e+f
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def add_gems
|
43
|
-
insert_into_file "Gemfile", after: "gem 'jquery-rails'" do
|
44
|
-
a = "\n\ngem 'bcrypt-ruby', '~> 3.0.0'"
|
45
|
-
a
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def create_migration_user
|
50
|
-
copy_file "create_users.rb", "db/migrate/00_create_users.rb"
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
5
|
+
# Your code goes here...
|
6
|
+
end
|