Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

Commit b361fd2

Browse files
committed
Merge pull request #594 from simonv3/master
Confirmation Non Manditory
2 parents 2392069 + d8ba3fe commit b361fd2

File tree

22 files changed

+144
-273
lines changed

22 files changed

+144
-273
lines changed

app/assets/stylesheets/styles/_variables.scss

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ $of-orange: #e69138;
1010
$of-blue: #3c78d8;
1111
$of-purple: #674ea7;
1212
$of-green: #6aa84f;
13-
$of-green2: #5E9546;
14-
$of-blue-grey: #ECEFF0;
13+
$of-green2: #5e9546;
14+
$of-blue-grey: #eCeff0;
1515
$of-red: #cc0000;
1616
$of-yellow: #f1c232;
1717
$of-dark: #4a4a4a;
@@ -22,11 +22,11 @@ $white: #ffffff;
2222
$gray-bg: #f9f9f9;
2323

2424
// We use these as default colors throughout
25-
$primary-color: #99B36C; // #008CBA;
25+
$primary-color: #99b36c; // #008CBA;
2626
$secondary-color: #e7e7e7;
2727
$alert-color: #ff6666;
28-
$success-color: #74E29D;
29-
$warning-color: #f08a24;
28+
$success-color: #74e29d;
29+
$warning-color: #f5c18c;
3030
$info-color: #eecb91;
3131

3232
// OpenFarm Colors

app/assets/stylesheets/styles/components/_alerts.css renamed to app/assets/stylesheets/styles/components/_alerts.css.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@
1010
.home-alert-wrapper{
1111
height: 0;
1212
}
13+
14+
.warning {
15+
color: $of-dark;
16+
}
Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
.infos{
1+
.infos {
22
text-align: center;
33
font-size: 1.2rem;
44
margin-bottom: 4rem;
55

6-
.image{
6+
.image {
77
height: 80px;
88
margin-bottom: 1rem;
99
position: relative;
1010
}
1111

12-
img{
12+
img {
1313
margin: 0;
1414
position: absolute;
1515
top: 50%;
@@ -18,14 +18,28 @@
1818
transform: translate(-50%, -50%)
1919
}
2020

21-
p{
21+
p {
2222
width: 80%;
2323
line-height: 1.2;
2424
color: $of-dark;
2525
margin: 0 auto;
2626
}
2727
}
2828

29-
.sign-in{
29+
input + small {
30+
top: -1rem;
31+
position: relative;
32+
}
33+
34+
.sign-in {
3035
margin-bottom: 4rem;
3136
}
37+
38+
.button-wrapper {
39+
text-align: center;
40+
}
41+
42+
.sign-up {
43+
margin-top: 1rem;
44+
text-align: right;
45+
}

app/controllers/application_controller.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class ApplicationController < ActionController::Base
77
# Allow certain fields for devise - needed in Rails 4.0+
88
before_filter :update_sanitized_params, if: :devise_controller?
99

10-
before_action :set_locale
10+
before_action :set_locale, :check_for_confirmation
1111

1212
def default_url_options(options = {})
1313
{ locale: I18n.locale }
@@ -17,6 +17,12 @@ def set_locale
1717
I18n.locale = params[:locale] || I18n.default_locale
1818
end
1919

20+
def check_for_confirmation
21+
if current_user && !current_user.confirmed?
22+
flash[:warning] = I18n.t('users.need_confirmation')
23+
end
24+
end
25+
2026
protected
2127

2228
# This method allows devise to pass non standard attributes through and

app/controllers/registrations_controller.rb

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,18 @@ def destroy
1111

1212
protected
1313

14-
# TODO: this isn't relevant anymore now that confirmation
15-
# emails are getting sent on sign up. There must be a way to
16-
# figure this out though:
17-
# have a look at: http://stackoverflow.com/questions/6499589/devise-redirect-page-after-confirmation
18-
1914
# https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-on-successful-sign-up-(registration)
20-
# def after_sign_up_path_for(resource)
21-
# # stored resource gets cleared after it gets called apparently
22-
# go_to = stored_location_for(resource)
23-
# if go_to
24-
# go_to || request.referer || root_path
25-
# else
26-
# url_for(controller: 'users',
27-
# action: 'finish')
28-
# end
29-
# end
15+
def after_sign_up_path_for(resource)
16+
# stored resource gets cleared after it gets called apparently
17+
go_to = stored_location_for(resource)
18+
if !resource.confirmed?
19+
resource.send_confirmation_instructions
20+
end
21+
if go_to
22+
go_to || request.referer || root_path
23+
else
24+
url_for(controller: 'users',
25+
action: 'finish')
26+
end
27+
end
3028
end

app/controllers/requirements_controller.rb

Lines changed: 0 additions & 23 deletions
This file was deleted.

app/controllers/users_controller.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@ class UsersController < ApplicationController
44

55
def update
66
authorize current_user
7+
8+
user_settings = {
9+
units: params[:units],
10+
location: params[:location]
11+
}
12+
713
@outcome = Users::UpdateUser.run(
814
user: params,
15+
user_setting: user_settings,
916
id: "#{current_user._id}")
1017

1118
if @outcome.errors

app/models/requirement.rb

Lines changed: 0 additions & 10 deletions
This file was deleted.

app/models/requirement_option.rb

Lines changed: 0 additions & 9 deletions
This file was deleted.

app/models/user.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,10 @@ class User
6565
def user_setting
6666
UserSetting.find_or_create_by(user: self)
6767
end
68+
69+
protected
70+
71+
def confirmation_required?
72+
false
73+
end
6874
end

0 commit comments

Comments
 (0)