Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
155 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
component | ||
extends="Controller" | ||
hint="Handles email confirmation requests." | ||
{ | ||
/** | ||
* @hint Constructor. | ||
*/ | ||
public void function init() { | ||
super.init(); | ||
filters(through="isAuthenticated,isAuthorized,redirectIfConfirmed", except="update"); | ||
} | ||
|
||
// -------------------------------------------------- | ||
// Filters | ||
|
||
/** | ||
* @hint Redirect the user if their email is already confirmed. | ||
*/ | ||
public void function redirectIfConfirmed() { | ||
if ( user.confirmed ) { | ||
redirectTo(route="profile", key=user.id, message="Your email address was previously confirmed.", messageType="warning"); | ||
} | ||
} | ||
|
||
// -------------------------------------------------- | ||
// RESTful Actions | ||
|
||
/** | ||
* @hint Renders a page where users request an email with instructions to confirm their email address. | ||
*/ | ||
public void function new() {} | ||
|
||
/** | ||
* @hint Sends an email with instructions to confirm email address. | ||
*/ | ||
public void function create() { | ||
user.update(emailConfirmationToken = user.generateToken()); | ||
//sendMail(to=user.email, subject="Email confirmation", template="/templates/emailConfirmation", user=user); | ||
redirectTo(route="profile", key=user.id, message="Email sent! Please see email for instructions.", messageType="success"); | ||
} | ||
|
||
/** | ||
* @hint Updates the user to confirmed status. | ||
*/ | ||
public void function update() { | ||
user = model("user").findOneByEmailConfirmationToken(params.key); | ||
if ( isObject(user) && user.update(confirmed = 1, emailConfirmationToken = "") ) { | ||
redirectTo(controller="users", action="show", key=user.id, message="Account confirmed successfully.", messageType="success"); | ||
} | ||
else { | ||
redirectTo(route="home", message="No such user.", messageType="error"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<cfoutput> | ||
|
||
#contentFor(pageTitle="Email Confirmation")# | ||
|
||
<div class="container"> | ||
<div class="page-header"> | ||
<h1>Email Confirmation</h1> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="span10"> | ||
#flashMessageTag()# | ||
|
||
<cfif user.confirmed> | ||
<p>Your email address has been confirmed previously.</p> | ||
<cfelse> | ||
<p>Click below to receive a new email with instructions for confirming your account.</p> | ||
</cfif> | ||
|
||
#startFormTag(action="create", key=user.id)# | ||
<fieldset> | ||
<div class="clearfix"> | ||
<label for="email">E-mail Address</label> | ||
<div class="input"> | ||
#textField(objectName="user", property="email", label=false, disabled=true)# | ||
</div> | ||
</div> | ||
<div class="actions"> | ||
#submitTag(value="Send Email", class="btn primary")# #linkTo(text="Cancel", controller="sessions", action="new", class="btn")# | ||
</div> | ||
</fieldset> | ||
#endFormTag()# | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</cfoutput> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<cfoutput> | ||
|
||
<h1>Dear #user.name#,</h1> | ||
<p>You need to confirm your e-mail address. Please click on the link below to do so:</p> | ||
<p>#URLFor(controller="confirmations", action="update", onlyPath=false, key=user.emailConfirmationToken)#</p> | ||
<p>If clicking the above link does not work, just copy it and paste the URL in a new browser window instead.</p> | ||
<p>Thanks!</p> | ||
|
||
</cfoutput> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters