Accepted_terms checkbox field required in register form and invitation register form

stable
Daniel García 2018-05-18 15:00:43 +02:00 committed by Alex Hermida
parent aa10d7b1ed
commit 1af9fb92e2
13 changed files with 74 additions and 42 deletions

View File

@ -243,7 +243,7 @@ class AuthService extends taiga.Service
user = @.getUser() user = @.getUser()
if not user or user.read_new_terms if not user or user.read_new_terms
return return
@termsAnnouncementService.show('GDPR', 'General Data Protection Regulation - Read more!') @termsAnnouncementService.show()
module.service("$tgAuth", AuthService) module.service("$tgAuth", AuthService)

View File

@ -1611,7 +1611,10 @@
"NEW_USER": "{{username}} has joined Taiga" "NEW_USER": "{{username}} has joined Taiga"
}, },
"LEGAL": { "LEGAL": {
"TERMS_OF_SERVICE_AND_PRIVACY_POLICY_AD": "<span>When creating a new account, you agree to our <br /></span><a href=\"{{ termsOfServiceUrl }}\" title=\"See terms of service\" target=\"_blank\">terms of service</a><span> and </span><a href=\"{{ privacyPolicyUrl }}\" title=\"See privacy policy\" target=\"_blank\">privacy policy</a>." "TERMS_OF_SERVICE_AND_PRIVACY_POLICY_AD": "<span>When creating a new account, you agree to our </span><a href=\"{{ termsOfServiceUrl }}\" title=\"See terms of service\" target=\"_blank\">terms of service</a><span> and </span><a href=\"{{ privacyPolicyUrl }}\" title=\"See privacy policy\" target=\"_blank\">privacy policy</a>.",
"GDPR_ANNOUNCEMENT_TITLE": "General Data Protection Regulation (GDPR)",
"GDPR_ANNOUNCEMENT_DESCRIPTION": "Your saw this comming, right?. Updates to our Terms of Service",
"GDPR_ANNOUNCEMENT_INFOLINK": "Please read our announcement here"
}, },
"EXTERNAL_APP": { "EXTERNAL_APP": {
"PAGE_TITLE": "An external app requires authentication", "PAGE_TITLE": "An external app requires authentication",

View File

@ -23,8 +23,11 @@
### ###
TermsAnnouncementDirective = (TermsAnnouncementService, $repo, $auth) -> TermsAnnouncementDirective = (TermsAnnouncementService, $repo, $auth, $config) ->
link = (scope, el, attrs) -> link = (scope, el, attrs) ->
scope.privacyPolicyUrl = $config.get("privacyPolicyUrl")
scope.termsOfServiceUrl = $config.get("termsOfServiceUrl")
scope.GDPRUrl = $config.get("GDPRUrl")
return { return {
restrict: "AE", restrict: "AE",
@ -35,7 +38,7 @@ TermsAnnouncementDirective = (TermsAnnouncementService, $repo, $auth) ->
TermsAnnouncementService.open = false TermsAnnouncementService.open = false
user = $auth.getUser() user = $auth.getUser()
onSuccess = (data) => onSuccess = (data) ->
$auth.setUser(data) $auth.setUser(data)
user.read_new_terms = true user.read_new_terms = true
@ -44,12 +47,6 @@ TermsAnnouncementDirective = (TermsAnnouncementService, $repo, $auth) ->
Object.defineProperties(this, { Object.defineProperties(this, {
open: { open: {
get: () -> return TermsAnnouncementService.open get: () -> return TermsAnnouncementService.open
},
title: {
get: () -> return TermsAnnouncementService.title
},
desc: {
get: () -> return TermsAnnouncementService.desc
} }
}) })
link: link, link: link,
@ -59,7 +56,8 @@ TermsAnnouncementDirective = (TermsAnnouncementService, $repo, $auth) ->
TermsAnnouncementDirective.$inject = [ TermsAnnouncementDirective.$inject = [
"tgTermsAnnouncementService", "tgTermsAnnouncementService",
"$tgRepo", "$tgRepo",
"$tgAuth" "$tgAuth",
"$tgConfig"
] ]
angular.module("taigaComponents") angular.module("taigaComponents")

View File

@ -1,9 +1,14 @@
.terms-announcement(ng-class="{visible: vm.open}") .terms-announcement(ng-class="{visible: vm.open && privacyPolicyUrl && termsOfServiceUrl && GDPRUrl}")
.terms-announcement-inner .terms-announcement-inner
img.anouncement-decoration(src="/#{v}/images/notification-decoration.png", alt="Loading...") img.announcement-decoration(src="/#{v}/images/notification-decoration.png", alt="Loading...")
.text .text
h2.title {{vm.title}} h2.title {{'LEGAL.GDPR_ANNOUNCEMENT_TITLE' | translate}}
p.warning(ng-bind-html="vm.desc") p.warning {{ 'LEGAL.GDPR_ANNOUNCEMENT_DESCRIPTION' | translate }}
a.gig-title(
href="{{ GDPRUrl }}"
target="_blank"
rel="nofollow"
) {{'LEGAL.GDPR_ANNOUNCEMENT_INFOLINK' | translate}}
a.close( a.close(
ng-click="vm.close()" ng-click="vm.close()"
href="" href=""

View File

@ -3,7 +3,6 @@
align-content: center; align-content: center;
background: $tribe-primary; background: $tribe-primary;
display: flex; display: flex;
height: 0;
justify-content: center; justify-content: center;
overflow: hidden; overflow: hidden;
pointer-events: none; pointer-events: none;
@ -19,7 +18,7 @@
width: 100%; width: 100%;
} }
&.visible { &.visible {
height: 146px; min-height: 146px;
pointer-events: auto; pointer-events: auto;
transition-delay: 0s; transition-delay: 0s;
width: 100%; width: 100%;
@ -35,6 +34,7 @@
max-width: 1200px; max-width: 1200px;
.announcement-decoration { .announcement-decoration {
align-self: flex-end; align-self: flex-end;
height: auto;
margin-right: 1rem; margin-right: 1rem;
} }
.text { .text {
@ -58,11 +58,11 @@
.close { .close {
display: block; display: block;
position: absolute; position: absolute;
right: 0; right: .5rem;
top: 1rem; top: 1rem;
svg { svg {
@include svg-size(2rem); @include svg-size(2rem);
fill: lighten($tribe-secondary, 15%); fill: $mass-white;
pointer-events: none; pointer-events: none;
transition: fill .2s; transition: fill .2s;
&:hover { &:hover {
@ -70,4 +70,7 @@
} }
} }
} }
a {
color: $mass-white;
}
} }

View File

@ -14,18 +14,14 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
# File: notification.service.coffee # File: terms-announcement.service.coffee
### ###
class TermsAnnouncementService extends taiga.Service class TermsAnnouncementService extends taiga.Service
constructor: () -> constructor: () ->
@.open = false @.open = false
@.title = ""
@.desc = ""
show: (title, desc) -> show: () ->
@.open = true @.open = true
@.title = title
@.desc = desc
angular.module("taigaComponents").service("tgTermsAnnouncementService", TermsAnnouncementService) angular.module("taigaComponents").service("tgTermsAnnouncementService", TermsAnnouncementService)

View File

@ -27,11 +27,19 @@ TermsOfServiceAndPrivacyPolicyNoticeDirective = ($config) ->
link = (scope, el, attrs) -> link = (scope, el, attrs) ->
scope.privacyPolicyUrl = $config.get("privacyPolicyUrl") scope.privacyPolicyUrl = $config.get("privacyPolicyUrl")
scope.termsOfServiceUrl = $config.get("termsOfServiceUrl") scope.termsOfServiceUrl = $config.get("termsOfServiceUrl")
scope.target = false
el.on "change", "input[name='accepted_terms']", (event) ->
target = angular.element(event.currentTarget)
scope.target = target.is(":checked")
scope.$apply()
return { return {
restrict: "AE", restrict: "AE",
scope: {},
link: link, link: link,
scope: {
target: "="
}
templateUrl: "components/terms-of-service-and-privacy-policy-notice/terms-of-service-and-privacy-policy-notice.html" templateUrl: "components/terms-of-service-and-privacy-policy-notice/terms-of-service-and-privacy-policy-notice.html"
} }

View File

@ -1,5 +1,10 @@
p.register-text( p.register-terms(ng-if="privacyPolicyUrl && termsOfServiceUrl")
ng-if="privacyPolicyUrl && termsOfServiceUrl" input.accepted_terms(
type="checkbox"
data-required="true"
name="accepted_terms"
)
span.register-text(
translate="LEGAL.TERMS_OF_SERVICE_AND_PRIVACY_POLICY_AD" translate="LEGAL.TERMS_OF_SERVICE_AND_PRIVACY_POLICY_AD"
translate-values="{termsOfServiceUrl: termsOfServiceUrl, privacyPolicyUrl: privacyPolicyUrl}" translate-values="{termsOfServiceUrl: termsOfServiceUrl, privacyPolicyUrl: privacyPolicyUrl}"
) )

View File

@ -43,12 +43,13 @@ form.register-form
placeholder="{{'REGISTER_FORM.PLACEHOLDER_PASSWORD' | translate}}" placeholder="{{'REGISTER_FORM.PLACEHOLDER_PASSWORD' | translate}}"
) )
//- Only displays terms notice when terms plugin is loaded.
tg-terms-of-service-and-privacy-policy-notice(target="dataRegister.accepted_terms")
fieldset fieldset
button.button-register.button-green.submit-button( button.button-register.button-green.submit-button(
type="submit" type="submit"
ng-disabled="dataRegister.accepted_terms == false"
title="{{'REGISTER_FORM.ACTION_SIGN_UP' | translate}}" title="{{'REGISTER_FORM.ACTION_SIGN_UP' | translate}}"
translate="REGISTER_FORM.ACTION_SIGN_UP" translate="REGISTER_FORM.ACTION_SIGN_UP"
) )
//- Only displays terms notice when terms plugin is loaded.
tg-terms-of-service-and-privacy-policy-notice

View File

@ -45,9 +45,13 @@ div.register-form-container(tg-register)
placeholder="{{'REGISTER_FORM.PLACEHOLDER_PASSWORD' | translate}}" placeholder="{{'REGISTER_FORM.PLACEHOLDER_PASSWORD' | translate}}"
) )
//- Only displays terms notice when terms plugin is loaded.
tg-terms-of-service-and-privacy-policy-notice(target="data.accepted_terms")
fieldset fieldset
button.button-register.button-green.submit-button( button.button-register.button-green.submit-button(
type="submit" type="submit"
ng-disabled="data.accepted_terms == false"
title="{{'REGISTER_FORM.ACTION_SIGN_UP' | translate}}" title="{{'REGISTER_FORM.ACTION_SIGN_UP' | translate}}"
translate="REGISTER_FORM.ACTION_SIGN_UP" translate="REGISTER_FORM.ACTION_SIGN_UP"
) )
@ -60,9 +64,6 @@ div.register-form-container(tg-register)
ng-include="plugin.template" ng-include="plugin.template"
) )
//- Only displays terms notice when terms plugin is loaded.
tg-terms-of-service-and-privacy-policy-notice
a.register-text-top( a.register-text-top(
href="" href=""
title="{{'REGISTER_FORM.TITLE_LINK_LOGIN' | translate}}" title="{{'REGISTER_FORM.TITLE_LINK_LOGIN' | translate}}"

View File

@ -6,6 +6,7 @@
flex-direction: row; flex-direction: row;
justify-content: center; justify-content: center;
left: 0; left: 0;
overflow-y: auto;
position: fixed; position: fixed;
right: 0; right: 0;
top: 0; top: 0;
@ -45,11 +46,18 @@
} }
.login-text, .login-text,
.register-text { .register-text {
text-align: center; margin-left: .5rem;
a:hover { padding-bottom: 1rem;
a {
text-decoration: underline;
&:hover {
color: $primary-light; color: $primary-light;
} }
} }
}
.register-terms {
margin: .5rem 0 .75rem;
}
.button { .button {
color: $white; color: $white;
display: block; display: block;

View File

@ -87,6 +87,10 @@
} }
.register-text { .register-text {
color: $white; color: $white;
font-size: .9rem;
margin-left: .5rem;
padding-bottom: 1rem;
text-align: left;
a { a {
color: $primary; color: $primary;
} }

View File

@ -2,7 +2,7 @@
display: block; display: block;
.register-text-top { .register-text-top {
display: block; display: block;
margin-bottom: 1rem; margin: 1rem 0;
text-align: center; text-align: center;
} }
.register-text { .register-text {