Skip to content

Commit

Permalink
Streamline registration templates
Browse files Browse the repository at this point in the history
  • Loading branch information
mlewis-everley committed Feb 22, 2018
1 parent d60cd34 commit debec2f
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 61 deletions.
32 changes: 23 additions & 9 deletions code/control/Users_Register_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,8 @@ public function RelativeLink($action = null)
public function index(SS_HTTPRequest $request)
{
$this->customise(array(
'Title' => "Register",
'ClassName' => 'RegisterPage',
'Content' => '',
'Title' => _t('Users.Register', 'Register'),
'MetaTitle' => _t('Users.Register', 'Register'),
'Form' => $this->RegisterForm(),
));

Expand All @@ -145,6 +144,11 @@ public function index(SS_HTTPRequest $request)
*/
public function sendverification(SS_HTTPRequest $request)
{
// If we don't allow verification emails, return an error
if (!Users::config()->send_verification_email) {
return $this->httpError(400);
}

$sent = false;

if (Member::currentUserID()) {
Expand All @@ -153,17 +157,22 @@ public function sendverification(SS_HTTPRequest $request)
$member = Member::get()->byID($this->getRequest()->param("ID"));
}

if ($member && !$member->isVerified() && Users::config()->send_verification_email) {
if ($member && !$member->isVerified()) {
$sent = $this->send_verification_email($member);
} else {
$sent = false;
}

$this->customise(array(
"ClassName" => "RegisterPage",
"Title" => _t('Users.AccountVerification','Account Verification'),
"MetaTitle" => _t('Users.AccountVerification','Account Verification'),
"Content" => $this->renderWith(
"UsersSendVerificationContent",
array("Sent" => $sent)
),
"Sent" => $sent
));

$this->extend("updateSendVerificationAction");

return $this->renderWith(array(
"Users_Register_sendverification",
"Users",
Expand All @@ -180,7 +189,7 @@ public function sendverification(SS_HTTPRequest $request)
* @return HTMLText
*/
public function verify(SS_HTTPRequest $request)
{
{
$member = Member::get()->byID($this->getRequest()->param("ID"));
$code = $this->getRequest()->param("OtherID");
$verify = false;
Expand All @@ -201,7 +210,12 @@ public function verify(SS_HTTPRequest $request)
}

$this->customise(array(
"ClassName" => "RegisterPage",
"Title" => _t('Users.AccountVerification','Account Verification'),
"MetaTitle" => _t('Users.AccountVerification','Account Verification'),
"Content" => $this->renderWith(
"UsersVerifyContent",
array("Verify" => $verify)
),
"Verify" => $verify
));

Expand Down
14 changes: 14 additions & 0 deletions templates/Includes/UsersSendVerificationContent.ss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<% if $Sent %>
<p><% _t('Users.VerificationSent','A verification has been sent to your registered email address.') %></p>
<p><% _t('Users.NextSteps','You will receive an email with a verification link. Clicking the link will verify your account.') %></p>
<% else %>
<p><% _t('Users.NotVerificationSent','Unable to send verification.') %></p>
<% end_if %>

<% if $CurrentMember %>
<p>
<a class="btn" href="{$BaseHref}users/account">
<% _t("Users.BackToAccount", "Back to your account") %>
</a>
</p>
<% end_if %>
13 changes: 13 additions & 0 deletions templates/Includes/UsersVerifyContent.ss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<% if $Verify %>
<p><% _t('Users.VerifiedMessage','Your account has been now been verified.') %></p>
<% else %>
<p><% _t('Users.NotVerifiedMessage','Your account could not be verified.') %></p>
<% end_if %>

<% if $CurrentMember %>
<p>
<a class="btn" href="{$BaseHref}users/account">
<% _t("Users.BackToAccount", "Back to your account") %>
</a>
</p>
<% end_if %>
9 changes: 0 additions & 9 deletions templates/Layout/Users_Register.ss

This file was deleted.

22 changes: 0 additions & 22 deletions templates/Layout/Users_Register_sendverification.ss

This file was deleted.

21 changes: 0 additions & 21 deletions templates/Layout/Users_Register_verify.ss

This file was deleted.

0 comments on commit debec2f

Please sign in to comment.