Skip to content

Commit

Permalink
Add missing functions.cfm file
Browse files Browse the repository at this point in the history
  • Loading branch information
abitdodgy committed Jun 30, 2012
1 parent 6fb2247 commit 729ab16
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions controllers/Controller.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ component
*/
private void function isAuthenticated() {
if ( ! signedIn() ) {
dump(var=request, abort=true);
redirectTo(route="signIn");
}
}
Expand Down
41 changes: 41 additions & 0 deletions events/functions.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<cfscript>
// --------------------------------------------------
// New user session related functions
/**
* @hint Returns the user currently logged in.
*/
public any function currentUser() {
if ( signedIn() ) {
currentUser = model("user").findByKey(session.currentUser.id);
return currentUser;
}
}
/**
* @hint Is the user signed in?
*/
public boolean function signedIn() {
return StructKeyExists(session, "currentUser");
}
/**
* @hint Signs in the user.
*/
public void function signIn(required user) {
session.currentUser = {
id = arguments.user.id
};
}
/**
* @hint Signs the user out.
*/
public void function signOut() {
if ( signedIn() ) {
StructDelete(session, "currentUser");
}
}
</cfscript>

0 comments on commit 729ab16

Please sign in to comment.