83c4b6b8c7ac — Bill Welliver 17 years ago
clean up the auth controller stuff.
2 files changed, 26 insertions(+), 20 deletions(-)

M auth/classes/auth/controller.pike
M auth/templates/auth/login.phtml
M auth/classes/auth/controller.pike +23 -19
@@ 32,7 32,7 @@ object|function default_action;
 //! default startup method. sets @[default_action] to be the root of the 
 //! current application. custom applications should override this method 
 //! and set this value appropriately.
-static void start()
+void start()
 {
   default_action = app->controller;
 }

          
@@ 82,7 82,6 @@ function _login = login;
 
 public void login(Request id, Response response, Template.View t, mixed ... args)
 {
-
    if(!id->variables->return_to)
    {
       id->variables->return_to = ((id->misc->flash && id->misc->flash->from) ||

          
@@ 96,13 95,13 @@ public void login(Request id, Response r
          response->redirect(id->variables->return_to || default_action);
          return;
          break;
-      default:
+      case "Login":
         mixed r = find_user(id, response, t);
         if(r)
         {
            // success!
            id->misc->session_variables->logout = 0;
-           id->misc->session_variables["user"] = r[0];
+           id->misc->session_variables["user"] = r;
            if(search(id->variables->return_to, "?") < -1)
              id->variables->return_to = id->variables->return_to + "&" + time();
            else

          
@@ 133,26 132,31 @@ public void logout(Request id, Response 
 
 public void forgotpassword(Request id, Response response, Template.View t, mixed ... args)
 {
-  mixed r = find_user_password(id, response, t);
 
-  if(!r)
-  {
-    response->flash("Unable to find a user account with that username. Please try again.\n");
-  }
-  else
+  switch(id->variables->action)
   {
-    object tp = view->get_idview(password_template_name);
-
-    tp->add("password", r["password"]);
+    case "Locate":
+      mixed r = find_user_password(id, response, t);
 
-    string mailmsg = tp->render();
+      if(!r)
+      {
+        response->flash("Unable to find a user account with that username. Please try again.\n");
+      }
+      else
+      {
+        object tp = view->get_view(password_template_name);
 
-    Protocols.SMTP.Client(get_mail_host())->simple_mail(r["email"],
-                              "Your FinScribe password",
+        tp->add("password", r["password"]);
+
+        string mailmsg = tp->render();
+
+        Protocols.SMTP.Client(get_mail_host())->simple_mail(r["email"],
+                              "Your password",
                               get_return_address(),
                               mailmsg);
 
-    response->flash("Your password has been located and will be sent to the email address on record for your account.\n");
-    response->redirect(login);
-   }
+        response->flash("Your password has been located and will be sent to the email address on record for your account.\n");
+        response->redirect(login);
+       }
+  }
 }

          
M auth/templates/auth/login.phtml +3 -1
@@ 1,6 1,8 @@ 
 <title>Login</title>
    <h3>Login</h3>
    <p>
+<i><%flash%></i>
+   <p>
 <form action="<%action_url action="/auth/login" %>" id="loginform" method="post">
 <table>
 <tr>

          
@@ 24,4 26,4 @@ Password:</td><td>
 </table>
 </form>
 <p/>
-<a href="<%action_url action="/auth/forgotpassword"%>">Forgot password?</a>
+<a href="<%action_url action="forgotpassword"%>">Forgot password?</a>