diff options
Diffstat (limited to 'src/main/webapp/controllers/Controller.cfc')
-rw-r--r-- | src/main/webapp/controllers/Controller.cfc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/main/webapp/controllers/Controller.cfc b/src/main/webapp/controllers/Controller.cfc new file mode 100644 index 0000000..cfcb401 --- /dev/null +++ b/src/main/webapp/controllers/Controller.cfc @@ -0,0 +1,37 @@ +<!---
+ This is the parent controller file that all your controllers should extend.
+ You can add functions to this file to make them globally available in all your controllers.
+ Do not delete this file.
+--->
+<cfcomponent extends="Wheels">
+ <cfscript>
+ function init() {
+ filters(through="restoreSession"); + }
+ function restoreSession() {
+ if (StructKeyExists(cookie, "openid") AND StructKeyExists(cookie, "auth_token"))
+ {
+ openid = model("Users").findOne(where="identity='#cookie.openid#' AND auth_token='#cookie.auth_token#'");
+ if (IsObject(openid))
+ {
+ session.user = {};
+ session.user.id = openID.id;
+ session.user.openid_server = openID.openid_server;
+ session.user.identity = openID.identity;
+ session.user.auth_token = openID.auth_token;
+ session.user.email = openid.email;
+ session.user.firstname = openid.firstname;
+ session.user.lastname = openid.lastname;
+ }
+ } + }
+
+ function requireLoggedIn()
+ {
+ if (! StructKeyExists(session, "user"))
+ location(url="..", addToken=false);
+ }
+
+
+ </cfscript>
+</cfcomponent>
\ No newline at end of file |