jobshop 0.0.14 → 0.0.15
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.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/jobshop/application.scss +2 -3
- data/app/controllers/jobshop/application_controller.rb +62 -2
- data/app/controllers/jobshop/teams/lookups_controller.rb +14 -1
- data/app/mailers/jobshop/application_mailer.rb +8 -0
- data/app/mailers/jobshop/teams_mailer.rb +10 -0
- data/app/models/jobshop/user.rb +9 -2
- data/app/views/jobshop/teams_mailer/found_teams.text.erb +7 -0
- data/app/views/layouts/jobshop/mailer.text.erb +1 -0
- data/config/initializers/assets.rb +1 -1
- data/db/migrate/20160718130211_reindex_jobshop_users_by_email_and_team_id.rb +6 -0
- data/db/migrate/20160720201947_add_authentication_token_to_jobshop_users.rb +6 -0
- data/lib/jobshop/templates/dummy_template.rb +8 -0
- data/lib/jobshop/version.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b40482d948a58938955b3133971e53032caa54fb
|
|
4
|
+
data.tar.gz: fadf4c7b7f987f810b732a1eeded4ca4edaf2be7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ca99cbcb216815970ea4111c708c74450f49942c536ff14953c6f7c78f2d465dbb9bb4c6e1163823a1fe4aa81ee1fe482743d2539eeb3605c84d919e4ea0c5cf
|
|
7
|
+
data.tar.gz: 550c1aa4d0e8ac61a9e38b2c5742200f49d1ba819b8f9750f805941036b0f18ebb2914b879d8d1cd0e4c9c7e520e93ce7ae3ff05712a407b6753e1f38445d247
|
|
@@ -10,8 +10,8 @@ html, body {
|
|
|
10
10
|
font-family: "Roboto", "Helvetica", sans-serif;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
html { height: 100
|
|
14
|
-
body { min-height: 100%; }
|
|
13
|
+
html { height: 100%; }
|
|
14
|
+
body { min-height: 100%; margin: 0 auto; }
|
|
15
15
|
|
|
16
16
|
main {
|
|
17
17
|
display: flex;
|
|
@@ -22,7 +22,6 @@ main {
|
|
|
22
22
|
#register {
|
|
23
23
|
@extend .mdl-shadow--2dp;
|
|
24
24
|
|
|
25
|
-
margin: 1rem;
|
|
26
25
|
width: 100%;
|
|
27
26
|
|
|
28
27
|
@include tablet-up {
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
# Parts of this class borrowed from:
|
|
2
|
+
# https://gist.github.com/josevalim/fb706b1e933ef01e4fb6
|
|
3
|
+
# Thank you Jose Valim!
|
|
4
|
+
|
|
1
5
|
module Jobshop
|
|
2
6
|
class ApplicationController < ActionController::Base
|
|
3
7
|
include Pundit
|
|
@@ -6,10 +10,25 @@ module Jobshop
|
|
|
6
10
|
|
|
7
11
|
protect_from_forgery
|
|
8
12
|
|
|
13
|
+
before_action :authenticate_user_from_email!
|
|
9
14
|
before_action :authenticate_user!
|
|
10
15
|
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
# after_action :verify_authorized, except: :index
|
|
17
|
+
# after_action :verify_policy_scoped, :only => :index
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def authenticate_user_from_email!
|
|
22
|
+
token = EmailAuthenticationToken.new(
|
|
23
|
+
params.fetch(:user_email, nil),
|
|
24
|
+
params.fetch(:email_authentication_token, nil)
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
if token.valid?
|
|
28
|
+
sign_in token.user
|
|
29
|
+
token.destroy
|
|
30
|
+
end
|
|
31
|
+
end
|
|
13
32
|
|
|
14
33
|
def layout_for_application
|
|
15
34
|
if devise_controller? && controller_name == "sessions" ||
|
|
@@ -20,5 +39,46 @@ module Jobshop
|
|
|
20
39
|
"jobshop/application"
|
|
21
40
|
end
|
|
22
41
|
end
|
|
42
|
+
|
|
43
|
+
class EmailAuthenticationToken
|
|
44
|
+
attr_reader :token
|
|
45
|
+
|
|
46
|
+
def initialize(email, token)
|
|
47
|
+
@email = email
|
|
48
|
+
@token = token
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def valid?
|
|
52
|
+
user && token && !expired? && secure_compare
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def user
|
|
56
|
+
@user ||= Jobshop::User.where(email: @email)
|
|
57
|
+
.where.not(email_authentication_token_sent_at: nil).first
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def destroy
|
|
61
|
+
user.update({
|
|
62
|
+
email_authentication_token: nil,
|
|
63
|
+
email_authentication_token_sent_at: nil
|
|
64
|
+
})
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def secure_compare
|
|
68
|
+
# Notice how we use Devise.secure_compare to compare the token in the
|
|
69
|
+
# database with the token given in the params, mitigating timing
|
|
70
|
+
# attacks.
|
|
71
|
+
Devise.secure_compare(user.email_authentication_token, token)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def expired?
|
|
75
|
+
@expired ||= Time.now >= expires_on
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def expires_on
|
|
79
|
+
# TODO: Make token expiration configurable in initializers/jobshop.rb.
|
|
80
|
+
@expires_on ||= user.email_authentication_token_sent_at + 6.hours
|
|
81
|
+
end
|
|
82
|
+
end
|
|
23
83
|
end
|
|
24
84
|
end
|
|
@@ -9,7 +9,20 @@ module Jobshop
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def create
|
|
12
|
-
|
|
12
|
+
email_addresses = params[:user][:email].split(",").map(&:strip).take(5)
|
|
13
|
+
|
|
14
|
+
@lookup = Jobshop::User
|
|
15
|
+
.where(email: email_addresses)
|
|
16
|
+
.joins(:team)
|
|
17
|
+
.select("jobshop_users.id AS id",
|
|
18
|
+
"email",
|
|
19
|
+
"jobshop_teams.name AS team_name")
|
|
20
|
+
.group_by(&:email)
|
|
21
|
+
|
|
22
|
+
@lookup.each_pair do |email, teams|
|
|
23
|
+
Jobshop::TeamsMailer.found_teams(email, teams).deliver_later
|
|
24
|
+
end
|
|
25
|
+
|
|
13
26
|
redirect_to new_user_session_path
|
|
14
27
|
end
|
|
15
28
|
end
|
data/app/models/jobshop/user.rb
CHANGED
|
@@ -2,11 +2,18 @@ module Jobshop
|
|
|
2
2
|
class User < ApplicationRecord
|
|
3
3
|
# Include default devise modules. Others available are:
|
|
4
4
|
# :confirmable, :lockable, :timeoutable and :omniauthable
|
|
5
|
-
devise :database_authenticatable, :recoverable, :rememberable
|
|
5
|
+
devise :database_authenticatable, :recoverable, :rememberable
|
|
6
6
|
|
|
7
7
|
belongs_to :team, optional: true
|
|
8
8
|
has_one :default_dashboard, class_name: "Jobshop::Dashboard", through: :team
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
def generate_email_authentication_token
|
|
13
|
+
loop do
|
|
14
|
+
token = Devise.friendly_token
|
|
15
|
+
break token unless Jobshop::User.where(email_authentication_token: token).first
|
|
16
|
+
end
|
|
17
|
+
end
|
|
11
18
|
end
|
|
12
19
|
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= yield %>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Be sure to restart your server when you modify this file.
|
|
2
2
|
|
|
3
3
|
# Version of your assets, change this if you want to expire all your assets.
|
|
4
|
-
Rails.application.config.assets.version =
|
|
4
|
+
Rails.application.config.assets.version = "4"
|
|
5
5
|
|
|
6
6
|
# Add additional assets to the asset load path
|
|
7
7
|
# Rails.application.config.assets.paths << Emoji.images_path
|
|
@@ -22,6 +22,14 @@ unless Dir.exist?("db/migrate")
|
|
|
22
22
|
Dir.mkdir("db/migrate")
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
+
# Mailer previews don't really play nice with Engines so in the dummy app we
|
|
26
|
+
# create an initializer to expose them properly.
|
|
27
|
+
initializer "expose_mailer_previews.rb", <<-INITIALIZER.strip_heredoc
|
|
28
|
+
Rails.application.configure do
|
|
29
|
+
config.action_mailer.preview_path = "#{Jobshop::Engine.root}/spec/mailers"
|
|
30
|
+
end
|
|
31
|
+
INITIALIZER
|
|
32
|
+
|
|
25
33
|
route "mount Jobshop::Engine => \"/\""
|
|
26
34
|
|
|
27
35
|
rake "db:create"
|
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.15
|
|
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-07-
|
|
11
|
+
date: 2016-07-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: coffee-rails
|
|
@@ -328,6 +328,8 @@ files:
|
|
|
328
328
|
- app/controllers/jobshop/teams_controller.rb
|
|
329
329
|
- app/helpers/jobshop/application_helper.rb
|
|
330
330
|
- app/jobs/jobshop/application_job.rb
|
|
331
|
+
- app/mailers/jobshop/application_mailer.rb
|
|
332
|
+
- app/mailers/jobshop/teams_mailer.rb
|
|
331
333
|
- app/models/jobshop/application_record.rb
|
|
332
334
|
- app/models/jobshop/dashboard.rb
|
|
333
335
|
- app/models/jobshop/registration.rb
|
|
@@ -350,7 +352,9 @@ files:
|
|
|
350
352
|
- app/views/jobshop/dashboards/show.html.haml
|
|
351
353
|
- app/views/jobshop/teams/lookups/show.html.haml
|
|
352
354
|
- app/views/jobshop/teams/registrations/new.html.haml
|
|
355
|
+
- app/views/jobshop/teams_mailer/found_teams.text.erb
|
|
353
356
|
- app/views/layouts/jobshop/application.html.haml
|
|
357
|
+
- app/views/layouts/jobshop/mailer.text.erb
|
|
354
358
|
- app/views/layouts/jobshop/unauthenticated.html.haml
|
|
355
359
|
- config/initializers/assets.rb
|
|
356
360
|
- config/initializers/devise.rb
|
|
@@ -365,6 +369,8 @@ files:
|
|
|
365
369
|
- db/migrate/20160323132658_rename_configuration_token_to_registration_token.rb
|
|
366
370
|
- db/migrate/20160417210218_create_jobshop_dashboards.rb
|
|
367
371
|
- db/migrate/20160425062447_rename_site_to_team.rb
|
|
372
|
+
- db/migrate/20160718130211_reindex_jobshop_users_by_email_and_team_id.rb
|
|
373
|
+
- db/migrate/20160720201947_add_authentication_token_to_jobshop_users.rb
|
|
368
374
|
- db/migrate/keep
|
|
369
375
|
- lib/generators/jobshop/config/config_generator.rb
|
|
370
376
|
- lib/generators/jobshop/config/templates/jobshop.rb.tt
|