Skip to content

Commit

Permalink
allows more granular configuration of password reset and user registr…
Browse files Browse the repository at this point in the history
…ation urls
  • Loading branch information
mitchell852 authored and dewrich committed Sep 13, 2017
1 parent b663945 commit 703867d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
6 changes: 4 additions & 2 deletions traffic_ops/app/conf/cdn.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
no_account_found_msg => 'A Traffic Ops user account is required for access. Please contact your Traffic Ops user administrator.' # message to display if no TO account is found in tm_user
},
portal => {
base_url => 'http://localhost:8080', # this is where the traffic portal resides (a javascript client that consumes the TO API)
email_from => 'no-reply@traffic-portal-domain.com' # traffic portal email address
base_url => 'http://localhost:8080/!#/', # this is where the traffic portal resides (a javascript client that consumes the TO API). Trailing slash is important!
email_from => 'no-reply@traffic-portal-domain.com', # traffic portal email address
pass_reset_path => 'user', # path where user is sent to reset password. Leverages portal.base_url so you end up with http://localhost:8080/!#/path
user_register_path => 'user' # path where user is sent to complete user registration. Leverages portal.base_url so you end up with http://localhost:8080/!#/path
},

# 1st secret is used to generate new signatures. Older one kept around for existing signed cookies.
Expand Down
24 changes: 12 additions & 12 deletions traffic_ops/app/lib/MojoPlugins/Email.pm
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ sub register {
my $email_to = shift || confess("Please supply an email address.");
my $token = shift || confess("Please supply a GUID token");

my $portal_base_url = $self->config->{'portal'}{'base_url'};
my $portal_email_from = $self->config->{'portal'}{'email_from'};
my $portal_pass_reset_url = $self->config->{'portal'}{'base_url'} . $self->config->{'portal'}{'pass_reset_path'};
my $portal_email_from = $self->config->{'portal'}{'email_from'};

$self->app->log->info( "MOJO_CONFIG: " . $ENV{MOJO_CONFIG} );
$self->app->log->info( "portal_base_url: " . $portal_base_url );
$self->app->log->info( "portal_pass_reset_url: " . $portal_pass_reset_url );

my $tm_user = {
email => $email_to,
portal_base_url => $portal_base_url,
token => $token,
email => $email_to,
portal_pass_reset_url => $portal_pass_reset_url,
token => $token,
};

my $instance_name =
Expand Down Expand Up @@ -128,16 +128,16 @@ sub register {
my $email_to = shift || confess("Please supply an email address.");
my $token = shift || confess("Please supply a GUID token");

my $portal_base_url = $self->config->{'portal'}{'base_url'};
my $portal_email_from = $self->config->{'portal'}{'email_from'};
my $portal_user_register_url = $self->config->{'portal'}{'base_url'} . $self->config->{'portal'}{'user_register_path'};
my $portal_email_from = $self->config->{'portal'}{'email_from'};

$self->app->log->info( "MOJO_CONFIG: " . $ENV{MOJO_CONFIG} );
$self->app->log->info( "portal_base_url: " . $portal_base_url );
$self->app->log->info( "portal_user_register_url: " . $portal_user_register_url );

my $tm_user = {
email => $email_to,
portal_base_url => $portal_base_url,
token => $token,
email => $email_to,
portal_user_register_url => $portal_user_register_url,
token => $token,
};

my $instance_name =
Expand Down
2 changes: 1 addition & 1 deletion traffic_ops/app/templates/user/registration.mail.ep
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

<body>
<p>A new account has been created for you on the <%= $instance_name %> Portal. In the <%= $instance_name %> Portal, you'll find a dashboard that provides access to all of your delivery services.</p>
<a class="button_link" href="<%= $tm_user->{portal_base_url} %>/#/user/register?token=<%= $tm_user->{token} %>">Click to Finish Your Registration</a>
<a class="button_link" href="<%= $tm_user->{portal_user_register_url} %>?token=<%= $tm_user->{token} %>">Click to Finish Your Registration</a>
<p>Thank you,</p>
<p>The <%= $instance_name %> Team</p>
</body>
Expand Down
2 changes: 1 addition & 1 deletion traffic_ops/app/templates/user/reset_password.mail.ep
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<body>
<section>Someone has requested to change your password for the <%= $instance_name %>. If you requested this change, please click the link below and change your password. Otherwise, you can disregard this email.</section>
<p><a class="button_link" href="<%= $tm_user->{portal_base_url} %>/#!/user?token=<%= $tm_user->{token} %>">Click to Reset Your Password</a></p>
<p><a class="button_link" href="<%= $tm_user->{portal_pass_reset_url} %>?token=<%= $tm_user->{token} %>">Click to Reset Your Password</a></p>

<p>Thank you,</p>
<p>The <%= $instance_name %> Team</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@
</div>
</div>
<div class="form-group" ng-class="{'has-error': hasError(userForm.password), 'has-feedback': hasError(userForm.password)}">
<label class="control-label col-md-2 col-sm-2 col-xs-12">Password <span ng-if="settings.isNew">*</span></label>
<label class="control-label col-md-2 col-sm-2 col-xs-12">Password <span ng-if="settings.isNew || user.newUser">*</span></label>
<div class="col-md-10 col-sm-10 col-xs-12">
<input id="password" name="password" type="password" class="form-control" ng-model="user.localPasswd" ng-required="settings.isNew" ng-maxlength="40" ng-minlength="8" autofocus>
<input id="password" name="password" type="password" class="form-control" ng-model="user.localPasswd" ng-required="settings.isNew || user.newUser" ng-maxlength="40" ng-minlength="8" autofocus>
<small class="input-error" ng-show="hasPropertyError(userForm.password, 'required')">Required</small>
<small class="input-error" ng-show="hasPropertyError(userForm.password, 'maxlength')">Too Long</small>
<span ng-show="hasError(userForm.password)" class="form-control-feedback"><i class="fa fa-times"></i></span>
</div>
</div>
<div class="form-group" ng-class="{'has-error': hasError(userForm.confirmPassword), 'has-feedback': hasError(userForm.confirmPassword)}">
<label class="control-label col-md-2 col-sm-2 col-xs-12">Confirm Password <span ng-if="settings.isNew">*</span></label>
<label class="control-label col-md-2 col-sm-2 col-xs-12">Confirm Password <span ng-if="settings.isNew || user.newUser">*</span></label>
<div class="col-md-10 col-sm-10 col-xs-12">
<input id="confirmPassword" name="confirmPassword" type="password" class="form-control" ng-model="user.confirmLocalPasswd" match="user.localPasswd">
<small class="input-error" ng-show="hasPropertyError(userForm.confirmPassword, 'match')">[ Doesn't Match ]</small>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<li>
<div class="btn-group" uib-dropdown is-open="userMenu.isopen">
<button id="userButton" type="button" class="btn btn-link" uib-dropdown-toggle>
<span id="headerUsername">{{::user.username}}</span><span ng-if="user.newUser">New User</span> <i class="fa fa-angle-down fa-lg"></i>
<span id="headerUsername">{{::user.username}}</span> <i class="fa fa-angle-down fa-lg"></i>
</button>
<ul class="uib-dropdown-menu dropdown-usermenu animated fadeInDown" role="menu" aria-labelledby="userMenu-button">
<li><a ui-sref="trafficPortal.private.user.edit">Manage User Profile</a></li>
Expand Down

0 comments on commit 703867d

Please sign in to comment.