jobshop 0.0.2.6 → 0.0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/jobshop/sites_controller.rb +27 -0
- data/app/models/jobshop/site.rb +18 -0
- data/app/models/jobshop/user.rb +7 -0
- data/app/views/jobshop/sites/edit.html.haml +2 -0
- data/config/initializers/devise.rb +280 -0
- data/config/locales/devise.en.yml +62 -0
- data/config/routes.rb +6 -0
- data/db/migrate/20160314122952_devise_create_jobshop_users.rb +44 -0
- data/db/migrate/20160314190424_create_jobshop_sites.rb +13 -0
- data/lib/generators/jobshop/site/USAGE +8 -0
- data/lib/generators/jobshop/site/site_generator.rb +56 -0
- data/lib/jobshop/version.rb +2 -2
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f3e8c26d845ecd96c8025b67dcae9d7bb45aff5
|
4
|
+
data.tar.gz: bf7803985ef85e88a8aac65c5ef7489b2466ae2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80c26e4a84b6e9759485d710f28e1cd5cd63325f329e28da12b1d80734bdb0d433f036de02702c53448c7c4653c4ea8f5b7c4719721190cdfab33c1b4d30a3b0
|
7
|
+
data.tar.gz: d5e3e5b32afd4325425df88547b92bffa26358881a557ab7a0980c2203c229ce8a04b8015aecfc255c10005e6ff0bc460af00f4730bf4eed26e592ac0d6f5a6c
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_dependency "jobshop/application_controller"
|
2
|
+
|
3
|
+
module Jobshop
|
4
|
+
class SitesController < ApplicationController
|
5
|
+
before_action :authenticate_user!, unless: :configure_by_token?, only: :edit
|
6
|
+
|
7
|
+
def edit
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
def configure_by_token?
|
14
|
+
params[:configuration_token].present? && configuration_token_valid?
|
15
|
+
end
|
16
|
+
|
17
|
+
def configuration_token_valid?
|
18
|
+
encrypted_configuration_token = Devise.token_generator.digest(
|
19
|
+
Jobshop::Site, :configuration_token, params[:configuration_token])
|
20
|
+
|
21
|
+
configurable = Jobshop::Site.find_by(
|
22
|
+
configuration_token: encrypted_configuration_token)
|
23
|
+
|
24
|
+
configurable && configurable.configuration_token_period_valid?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Jobshop
|
2
|
+
class Site < ActiveRecord::Base
|
3
|
+
def generate_configuration_token
|
4
|
+
raw, encrypted = Devise.token_generator.generate(self.class, :configuration_token)
|
5
|
+
|
6
|
+
self.configuration_token = encrypted
|
7
|
+
self.configuration_token_sent_at = Time.now.utc
|
8
|
+
self.save(validate: false)
|
9
|
+
|
10
|
+
raw
|
11
|
+
end
|
12
|
+
|
13
|
+
def configuration_token_period_valid?
|
14
|
+
configuration_token_sent_at &&
|
15
|
+
configuration_token_sent_at.utc >= 30.minutes.ago.utc
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,280 @@
|
|
1
|
+
# Use this hook to configure devise mailer, warden hooks and so forth.
|
2
|
+
# Many of these configuration options can be set straight in your model.
|
3
|
+
Devise.setup do |config|
|
4
|
+
# The secret key used by Devise. Devise uses this key to generate
|
5
|
+
# random tokens. Changing this key will render invalid all existing
|
6
|
+
# confirmation, reset password and unlock tokens in the database.
|
7
|
+
# Devise will use the `secret_key_base` as its `secret_key`
|
8
|
+
# by default. You can change it below and use your own secret key.
|
9
|
+
# config.secret_key = ENV.fetch("DEVISE_SECRET_KEY")
|
10
|
+
|
11
|
+
# ==> Mailer Configuration
|
12
|
+
# Configure the e-mail address which will be shown in Devise::Mailer,
|
13
|
+
# note that it will be overwritten if you use your own mailer class
|
14
|
+
# with default "from" parameter.
|
15
|
+
config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
|
16
|
+
|
17
|
+
# Configure the class responsible to send e-mails.
|
18
|
+
# config.mailer = 'Devise::Mailer'
|
19
|
+
|
20
|
+
# Configure the parent class responsible to send e-mails.
|
21
|
+
# config.parent_mailer = 'ActionMailer::Base'
|
22
|
+
|
23
|
+
# ==> ORM configuration
|
24
|
+
# Load and configure the ORM. Supports :active_record (default) and
|
25
|
+
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
26
|
+
# available as additional gems.
|
27
|
+
require 'devise/orm/active_record'
|
28
|
+
|
29
|
+
# ==> Configuration for any authentication mechanism
|
30
|
+
# Configure which keys are used when authenticating a user. The default is
|
31
|
+
# just :email. You can configure it to use [:username, :subdomain], so for
|
32
|
+
# authenticating a user, both parameters are required. Remember that those
|
33
|
+
# parameters are used only when authenticating and not when retrieving from
|
34
|
+
# session. If you need permissions, you should implement that in a before
|
35
|
+
# filter. You can also supply a hash where the value is a boolean determining
|
36
|
+
# whether or not authentication should be aborted when the value is not
|
37
|
+
# present.
|
38
|
+
# config.authentication_keys = [:email]
|
39
|
+
|
40
|
+
# Configure parameters from the request object used for authentication. Each
|
41
|
+
# entry given should be a request method and it will automatically be passed
|
42
|
+
# to the find_for_authentication method and considered in your model lookup.
|
43
|
+
# For instance, if you set :request_keys to [:subdomain], :subdomain will be
|
44
|
+
# used on authentication. The same considerations mentioned for
|
45
|
+
# authentication_keys also apply to request_keys.
|
46
|
+
# config.request_keys = []
|
47
|
+
|
48
|
+
# Configure which authentication keys should be case-insensitive.
|
49
|
+
# These keys will be downcased upon creating or modifying a user and when used
|
50
|
+
# to authenticate or find a user. Default is :email.
|
51
|
+
config.case_insensitive_keys = [:email]
|
52
|
+
|
53
|
+
# Configure which authentication keys should have whitespace stripped. These
|
54
|
+
# keys will have whitespace before and after removed upon creating or
|
55
|
+
# modifying a user and when used to authenticate or find a user.
|
56
|
+
# Default is :email.
|
57
|
+
config.strip_whitespace_keys = [:email]
|
58
|
+
|
59
|
+
# Tell if authentication through request.params is enabled. True by default.
|
60
|
+
# It can be set to an array that will enable params authentication only for
|
61
|
+
# the given strategies, for example,
|
62
|
+
# `config.params_authenticatable = [:database]` will enable it only for
|
63
|
+
# database (email + password) authentication.
|
64
|
+
# config.params_authenticatable = true
|
65
|
+
|
66
|
+
# Tell if authentication through HTTP Auth is enabled. False by default.
|
67
|
+
# It can be set to an array that will enable http authentication only for the
|
68
|
+
# given strategies, for example, `config.http_authenticatable = [:database]` will
|
69
|
+
# enable it only for database authentication. The supported strategies are:
|
70
|
+
# :database = Support basic authentication with authentication key + password
|
71
|
+
# config.http_authenticatable = false
|
72
|
+
|
73
|
+
# If 401 status code should be returned for AJAX requests. True by default.
|
74
|
+
# config.http_authenticatable_on_xhr = true
|
75
|
+
|
76
|
+
# The realm used in Http Basic Authentication. 'Application' by default.
|
77
|
+
# config.http_authentication_realm = 'Application'
|
78
|
+
|
79
|
+
# It will change confirmation, password recovery and other workflows
|
80
|
+
# to behave the same regardless if the e-mail provided was right or wrong.
|
81
|
+
# Does not affect registerable.
|
82
|
+
config.paranoid = true
|
83
|
+
|
84
|
+
# By default Devise will store the user in session. You can skip storage for
|
85
|
+
# particular strategies by setting this option.
|
86
|
+
# Notice that if you are skipping storage for all authentication paths, you
|
87
|
+
# may want to disable generating routes to Devise's sessions controller by
|
88
|
+
# passing skip: :sessions to `devise_for` in your config/routes.rb
|
89
|
+
config.skip_session_storage = [:http_auth]
|
90
|
+
|
91
|
+
# By default, Devise cleans up the CSRF token on authentication to
|
92
|
+
# avoid CSRF token fixation attacks. This means that, when using AJAX
|
93
|
+
# requests for sign in and sign up, you need to get a new CSRF token
|
94
|
+
# from the server. You can disable this option at your own risk.
|
95
|
+
# config.clean_up_csrf_token_on_authentication = true
|
96
|
+
|
97
|
+
# ==> Configuration for :database_authenticatable
|
98
|
+
# For bcrypt, this is the cost for hashing the password and defaults to 11. If
|
99
|
+
# using other algorithms, it sets how many times you want the password to be
|
100
|
+
# hashed.
|
101
|
+
#
|
102
|
+
# Limiting the stretches to just one in testing will increase the performance
|
103
|
+
# of your test suite dramatically. However, it is STRONGLY RECOMMENDED to not
|
104
|
+
# use a value less than 10 in other environments. Note that, for bcrypt (the
|
105
|
+
# default algorithm), the cost increases exponentially with the number of
|
106
|
+
# stretches (e.g. a value of 20 is already extremely slow: approx. 60 seconds
|
107
|
+
# for 1 calculation).
|
108
|
+
config.stretches = Rails.env.test? ? 1 : 11
|
109
|
+
|
110
|
+
# Set up a pepper to generate the hashed password.
|
111
|
+
# config.pepper = '3220c00bce8dc5e166199dabfddef4790570ffdcd79bb3d9f51df02743cd00ae5a19463105d4d764ec03b14140a75777c0ae161a6108f2770c7fa1af12222384'
|
112
|
+
|
113
|
+
# Send a notification email when the user's password is changed
|
114
|
+
config.send_password_change_notification = false
|
115
|
+
|
116
|
+
# ==> Configuration for :confirmable
|
117
|
+
# A period that the user is allowed to access the website even without
|
118
|
+
# confirming their account. For instance, if set to 2.days, the user will be
|
119
|
+
# able to access the website for two days without confirming their account,
|
120
|
+
# access will be blocked just in the third day. Default is 0.days, meaning
|
121
|
+
# the user cannot access the website without confirming their account.
|
122
|
+
# config.allow_unconfirmed_access_for = 2.days
|
123
|
+
|
124
|
+
# A period that the user is allowed to confirm their account before their
|
125
|
+
# token becomes invalid. For example, if set to 3.days, the user can confirm
|
126
|
+
# their account within 3 days after the mail was sent, but on the fourth day
|
127
|
+
# their account can't be confirmed with the token any more.
|
128
|
+
# Default is nil, meaning there is no restriction on how long a user can take
|
129
|
+
# before confirming their account.
|
130
|
+
# config.confirm_within = 3.days
|
131
|
+
|
132
|
+
# If true, requires any email changes to be confirmed (exactly the same way as
|
133
|
+
# initial account confirmation) to be applied. Requires additional
|
134
|
+
# unconfirmed_email db field (see migrations). Until confirmed, new email is
|
135
|
+
# stored in unconfirmed_email column, and copied to email column on successful
|
136
|
+
# confirmation.
|
137
|
+
config.reconfirmable = true
|
138
|
+
|
139
|
+
# Defines which key will be used when confirming an account
|
140
|
+
# config.confirmation_keys = [:email]
|
141
|
+
|
142
|
+
# ==> Configuration for :rememberable
|
143
|
+
# The time the user will be remembered without asking for credentials again.
|
144
|
+
config.remember_for = 1.day
|
145
|
+
|
146
|
+
# Invalidates all the remember me tokens when the user signs out.
|
147
|
+
config.expire_all_remember_me_on_sign_out = false
|
148
|
+
|
149
|
+
# If true, extends the user's remember period when remembered via cookie.
|
150
|
+
# config.extend_remember_period = false
|
151
|
+
|
152
|
+
# Options to be passed to the created cookie. For instance, you can set
|
153
|
+
# secure: true in order to force SSL only cookies.
|
154
|
+
config.rememberable_options = { secure: true }
|
155
|
+
|
156
|
+
# ==> Configuration for :validatable
|
157
|
+
# Range for password length.
|
158
|
+
config.password_length = 8..72
|
159
|
+
|
160
|
+
# Email regex used to validate email formats. It simply asserts that
|
161
|
+
# one (and only one) @ exists in the given string. This is mainly
|
162
|
+
# to give user feedback and not to assert the e-mail validity.
|
163
|
+
# config.email_regexp = /\A[^@]+@[^@]+\z/
|
164
|
+
|
165
|
+
# ==> Configuration for :timeoutable
|
166
|
+
# The time you want to timeout the user session without activity. After this
|
167
|
+
# time the user will be asked for credentials again. Default is 30 minutes.
|
168
|
+
# config.timeout_in = 30.minutes
|
169
|
+
|
170
|
+
# ==> Configuration for :lockable
|
171
|
+
# Defines which strategy will be used to lock an account.
|
172
|
+
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
|
173
|
+
# :none = No lock strategy. You should handle locking by yourself.
|
174
|
+
# config.lock_strategy = :failed_attempts
|
175
|
+
|
176
|
+
# Defines which key will be used when locking and unlocking an account
|
177
|
+
# config.unlock_keys = [:email]
|
178
|
+
|
179
|
+
# Defines which strategy will be used to unlock an account.
|
180
|
+
# :email = Sends an unlock link to the user email
|
181
|
+
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
182
|
+
# :both = Enables both strategies
|
183
|
+
# :none = No unlock strategy. You should handle unlocking by yourself.
|
184
|
+
# config.unlock_strategy = :both
|
185
|
+
|
186
|
+
# Number of authentication tries before locking an account if lock_strategy
|
187
|
+
# is failed attempts.
|
188
|
+
# config.maximum_attempts = 20
|
189
|
+
|
190
|
+
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
191
|
+
# config.unlock_in = 1.hour
|
192
|
+
|
193
|
+
# Warn on the last attempt before the account is locked.
|
194
|
+
# config.last_attempt_warning = true
|
195
|
+
|
196
|
+
# ==> Configuration for :recoverable
|
197
|
+
#
|
198
|
+
# Defines which key will be used when recovering the password for an account
|
199
|
+
# config.reset_password_keys = [:email]
|
200
|
+
|
201
|
+
# Time interval you can reset your password with a reset password key.
|
202
|
+
# Don't put a too small interval or your users won't have the time to
|
203
|
+
# change their passwords.
|
204
|
+
config.reset_password_within = 6.hours
|
205
|
+
|
206
|
+
# When set to false, does not sign a user in automatically after their password is
|
207
|
+
# reset. Defaults to true, so a user is signed in automatically after a reset.
|
208
|
+
# config.sign_in_after_reset_password = true
|
209
|
+
|
210
|
+
# ==> Configuration for :encryptable
|
211
|
+
# Allow you to use another hashing or encryption algorithm besides bcrypt (default).
|
212
|
+
# You can use :sha1, :sha512 or algorithms from others authentication tools as
|
213
|
+
# :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
|
214
|
+
# for default behavior) and :restful_authentication_sha1 (then you should set
|
215
|
+
# stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
|
216
|
+
#
|
217
|
+
# Require the `devise-encryptable` gem when using anything other than bcrypt
|
218
|
+
# config.encryptor = :sha512
|
219
|
+
|
220
|
+
# ==> Scopes configuration
|
221
|
+
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
222
|
+
# "users/sessions/new". It's turned off by default because it's slower if you
|
223
|
+
# are using only default views.
|
224
|
+
config.scoped_views = true
|
225
|
+
|
226
|
+
# Configure the default scope given to Warden. By default it's the first
|
227
|
+
# devise role declared in your routes (usually :user).
|
228
|
+
# config.default_scope = :user
|
229
|
+
|
230
|
+
# Set this configuration to false if you want /users/sign_out to sign out
|
231
|
+
# only the current scope. By default, Devise signs out all scopes.
|
232
|
+
# config.sign_out_all_scopes = true
|
233
|
+
|
234
|
+
# ==> Navigation configuration
|
235
|
+
# Lists the formats that should be treated as navigational. Formats like
|
236
|
+
# :html, should redirect to the sign in page when the user does not have
|
237
|
+
# access, but formats like :xml or :json, should return 401.
|
238
|
+
#
|
239
|
+
# If you have any extra navigational formats, like :iphone or :mobile, you
|
240
|
+
# should add them to the navigational formats lists.
|
241
|
+
#
|
242
|
+
# The "*/*" below is required to match Internet Explorer requests.
|
243
|
+
# config.navigational_formats = ['*/*', :html]
|
244
|
+
|
245
|
+
# The default HTTP method used to sign out a resource. Default is :delete.
|
246
|
+
config.sign_out_via = :delete
|
247
|
+
|
248
|
+
# ==> OmniAuth
|
249
|
+
# Add a new OmniAuth provider. Check the wiki for more information on setting
|
250
|
+
# up on your models and hooks.
|
251
|
+
# config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
|
252
|
+
|
253
|
+
# ==> Warden configuration
|
254
|
+
# If you want to use other strategies, that are not supported by Devise, or
|
255
|
+
# change the failure app, you can configure them inside the config.warden block.
|
256
|
+
#
|
257
|
+
# config.warden do |manager|
|
258
|
+
# manager.intercept_401 = false
|
259
|
+
# manager.default_strategies(scope: :user).unshift :some_external_strategy
|
260
|
+
# end
|
261
|
+
|
262
|
+
# ==> Mountable engine configurations
|
263
|
+
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
|
264
|
+
# is mountable, there are some extra configurations to be taken into account.
|
265
|
+
# The following options are available, assuming the engine is mounted as:
|
266
|
+
#
|
267
|
+
# mount MyEngine, at: '/my_engine'
|
268
|
+
#
|
269
|
+
# The router that invoked `devise_for`, in the example above, would be:
|
270
|
+
config.router_name = :jobshop
|
271
|
+
|
272
|
+
# You probably want Devise's controllers to inherit from your engine's
|
273
|
+
# controller and not the main controller.
|
274
|
+
config.parent_controller = "Jobshop::ApplicationController"
|
275
|
+
|
276
|
+
#
|
277
|
+
# When using OmniAuth, Devise cannot automatically set OmniAuth path,
|
278
|
+
# so you need to do it manually. For the users scope, it would be:
|
279
|
+
# config.omniauth_path_prefix = '/my_engine/users/auth'
|
280
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
|
2
|
+
|
3
|
+
en:
|
4
|
+
devise:
|
5
|
+
confirmations:
|
6
|
+
confirmed: "Your email address has been successfully confirmed."
|
7
|
+
send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
|
8
|
+
send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
|
9
|
+
failure:
|
10
|
+
already_authenticated: "You are already signed in."
|
11
|
+
inactive: "Your account is not activated yet."
|
12
|
+
invalid: "Invalid %{authentication_keys} or password."
|
13
|
+
locked: "Your account is locked."
|
14
|
+
last_attempt: "You have one more attempt before your account is locked."
|
15
|
+
not_found_in_database: "Invalid %{authentication_keys} or password."
|
16
|
+
timeout: "Your session expired. Please sign in again to continue."
|
17
|
+
unauthenticated: "You need to sign in or sign up before continuing."
|
18
|
+
unconfirmed: "You have to confirm your email address before continuing."
|
19
|
+
mailer:
|
20
|
+
confirmation_instructions:
|
21
|
+
subject: "Confirmation instructions"
|
22
|
+
reset_password_instructions:
|
23
|
+
subject: "Reset password instructions"
|
24
|
+
unlock_instructions:
|
25
|
+
subject: "Unlock instructions"
|
26
|
+
password_change:
|
27
|
+
subject: "Password Changed"
|
28
|
+
omniauth_callbacks:
|
29
|
+
failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
|
30
|
+
success: "Successfully authenticated from %{kind} account."
|
31
|
+
passwords:
|
32
|
+
no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
|
33
|
+
send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
|
34
|
+
send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
|
35
|
+
updated: "Your password has been changed successfully. You are now signed in."
|
36
|
+
updated_not_active: "Your password has been changed successfully."
|
37
|
+
registrations:
|
38
|
+
destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
|
39
|
+
signed_up: "Welcome! You have signed up successfully."
|
40
|
+
signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
|
41
|
+
signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
|
42
|
+
signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
|
43
|
+
update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address."
|
44
|
+
updated: "Your account has been updated successfully."
|
45
|
+
sessions:
|
46
|
+
signed_in: "Signed in successfully."
|
47
|
+
signed_out: "Signed out successfully."
|
48
|
+
already_signed_out: "Signed out successfully."
|
49
|
+
unlocks:
|
50
|
+
send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
|
51
|
+
send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
|
52
|
+
unlocked: "Your account has been unlocked successfully. Please sign in to continue."
|
53
|
+
errors:
|
54
|
+
messages:
|
55
|
+
already_confirmed: "was already confirmed, please try signing in"
|
56
|
+
confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
|
57
|
+
expired: "has expired, please request a new one"
|
58
|
+
not_found: "not found"
|
59
|
+
not_locked: "was not locked"
|
60
|
+
not_saved:
|
61
|
+
one: "1 error prohibited this %{resource} from being saved:"
|
62
|
+
other: "%{count} errors prohibited this %{resource} from being saved:"
|
data/config/routes.rb
CHANGED
@@ -1,4 +1,10 @@
|
|
1
1
|
Jobshop::Engine.routes.draw do
|
2
|
+
get 'sites/edit'
|
3
|
+
|
4
|
+
devise_for :users, class_name: "Jobshop::User", module: :devise
|
5
|
+
|
6
|
+
resources :sites, only: [ :edit, :update ]
|
7
|
+
|
2
8
|
get "/" => "pages#show", page: "index"
|
3
9
|
get "/about" => redirect("https://jobshop.io"), as: :about
|
4
10
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class DeviseCreateJobshopUsers < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
enable_extension "pgcrypto" unless extension_enabled?("pgcrypto")
|
4
|
+
|
5
|
+
create_table :jobshop_users, id: :uuid, default: "gen_random_uuid()" do |t|
|
6
|
+
## Database authenticatable
|
7
|
+
t.string :email, null: false, default: ""
|
8
|
+
t.string :encrypted_password, null: false, default: ""
|
9
|
+
|
10
|
+
## Recoverable
|
11
|
+
t.string :reset_password_token
|
12
|
+
t.datetime :reset_password_sent_at
|
13
|
+
|
14
|
+
## Rememberable
|
15
|
+
t.datetime :remember_created_at
|
16
|
+
|
17
|
+
## Trackable
|
18
|
+
# t.integer :sign_in_count, default: 0, null: false
|
19
|
+
# t.datetime :current_sign_in_at
|
20
|
+
# t.datetime :last_sign_in_at
|
21
|
+
# t.string :current_sign_in_ip
|
22
|
+
# t.string :last_sign_in_ip
|
23
|
+
|
24
|
+
## Confirmable
|
25
|
+
# t.string :confirmation_token
|
26
|
+
# t.datetime :confirmed_at
|
27
|
+
# t.datetime :confirmation_sent_at
|
28
|
+
# t.string :unconfirmed_email # Only if using reconfirmable
|
29
|
+
|
30
|
+
## Lockable
|
31
|
+
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
|
32
|
+
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
33
|
+
# t.datetime :locked_at
|
34
|
+
|
35
|
+
|
36
|
+
t.timestamps null: false
|
37
|
+
end
|
38
|
+
|
39
|
+
add_index :jobshop_users, :email, unique: true
|
40
|
+
add_index :jobshop_users, :reset_password_token, unique: true
|
41
|
+
# add_index :jobshop_users, :confirmation_token, unique: true
|
42
|
+
# add_index :jobshop_users, :unlock_token, unique: true
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateJobshopSites < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
enable_extension "pgcrypto" unless extension_enabled?("pgcrypto")
|
4
|
+
|
5
|
+
create_table :jobshop_sites, id: :uuid, default: "gen_random_uuid()" do |t|
|
6
|
+
t.string :name
|
7
|
+
t.string :configuration_token
|
8
|
+
t.datetime :configuration_token_sent_at
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Jobshop
|
2
|
+
module Generators
|
3
|
+
class SiteGenerator < Rails::Generators::NamedBase
|
4
|
+
source_root File.expand_path("../templates", __FILE__)
|
5
|
+
|
6
|
+
desc "Create a jobshop site."
|
7
|
+
|
8
|
+
attr_reader :site, :link_text, :first_site
|
9
|
+
|
10
|
+
def require_environment
|
11
|
+
ENV['RAILS_ENV'] ||= "development"
|
12
|
+
require File.expand_path("config/environment.rb")
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_site
|
16
|
+
@site = Jobshop::Site.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def generate_token
|
20
|
+
@token = site.generate_configuration_token
|
21
|
+
end
|
22
|
+
|
23
|
+
def generate_secure_configuration_link
|
24
|
+
link_protocol = Rails.env.development? ? "http" : "https"
|
25
|
+
link_host = Rails.env.development? ? "localhost:3000" : "YOUR-HOST-NAME"
|
26
|
+
# TODO: Give environments besides development a decent host and
|
27
|
+
# protocol. HTTPS isn't mandatory in production but it is very, VERY
|
28
|
+
# highly recommended.
|
29
|
+
@link_text = Jobshop::Engine.routes.url_helpers.edit_site_url(
|
30
|
+
@site,
|
31
|
+
protocol: link_protocol,
|
32
|
+
host: link_host,
|
33
|
+
configuration_token: @token
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
def print_secure_configuration_link
|
38
|
+
say <<-MESSAGE
|
39
|
+
### JOBSHOP - IMPORTANT INFORMATION ############################################
|
40
|
+
|
41
|
+
Your Jobshop site "#{name}" has been initialized.
|
42
|
+
You may use the following link to complete the setup process.
|
43
|
+
|
44
|
+
#{link_text}
|
45
|
+
|
46
|
+
This link is valid for 30 minutes from now and will expire at:
|
47
|
+
#{30.minutes.from_now.in_time_zone("Eastern Time (US & Canada)")}
|
48
|
+
|
49
|
+
Thank you for using Jobshop!
|
50
|
+
|
51
|
+
################################################################################
|
52
|
+
MESSAGE
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/jobshop/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jobshop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank J. Mattia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coffee-rails
|
@@ -291,18 +291,28 @@ files:
|
|
291
291
|
- app/assets/stylesheets/jobshop/pages/index.scss
|
292
292
|
- app/controllers/jobshop/application_controller.rb
|
293
293
|
- app/controllers/jobshop/pages_controller.rb
|
294
|
+
- app/controllers/jobshop/sites_controller.rb
|
294
295
|
- app/helpers/jobshop/application_helper.rb
|
295
296
|
- app/jobs/jobshop/application_job.rb
|
296
297
|
- app/models/application_record.rb
|
298
|
+
- app/models/jobshop/site.rb
|
299
|
+
- app/models/jobshop/user.rb
|
297
300
|
- app/policies/jobshop/application_policy.rb
|
298
301
|
- app/views/jobshop/pages/index.html.haml
|
302
|
+
- app/views/jobshop/sites/edit.html.haml
|
299
303
|
- app/views/layouts/jobshop/application.html.haml
|
300
304
|
- config/initializers/assets.rb
|
305
|
+
- config/initializers/devise.rb
|
306
|
+
- config/locales/devise.en.yml
|
301
307
|
- config/routes.rb
|
308
|
+
- db/migrate/20160314122952_devise_create_jobshop_users.rb
|
309
|
+
- db/migrate/20160314190424_create_jobshop_sites.rb
|
302
310
|
- db/migrate/keep
|
303
311
|
- lib/generators/jobshop/config/config_generator.rb
|
304
312
|
- lib/generators/jobshop/config/templates/jobshop.rb.tt
|
305
313
|
- lib/generators/jobshop/orm_helpers.rb
|
314
|
+
- lib/generators/jobshop/site/USAGE
|
315
|
+
- lib/generators/jobshop/site/site_generator.rb
|
306
316
|
- lib/jobshop.rb
|
307
317
|
- lib/jobshop/dummy.rb
|
308
318
|
- lib/jobshop/engine.rb
|