Add account recovering
authorChristian Thaeter <ct@pipapo.org>
Wed, 30 Jan 2008 05:21:59 +0000 (06:21 +0100)
committerChristian Thaeter <ct@pipapo.org>
Wed, 30 Jan 2008 05:21:59 +0000 (06:21 +0100)
Sends the activation email again to the stored email address

src/account.c
src/query.c
src/query.h
src/webgit.h

index d1cc8e0..e5f3fc4 100644 (file)
@@ -264,29 +264,17 @@ webgit_account_menu_action (struct webgit_query* query)
 
   if (query->accountdir && query->secret)
     {
-      if (!query->user)
-        {
-          /* create account or recover */
-        }
-      else if (query->user)
+      if (query->user && query->ssign)
         {
-          if (!query->ssign)
-            {
-              /* create 2nd step, must not exist send signed cookie */
-            }
-          else
-            {
-              /* change name/email */
-              html_list_append (menu,
-                                "Preferences", "<br />",
-                                "Deactivate&nbsp;Account", "<br />");
-            }
+          html_list_append (menu,
+                            webgit_account_logout_link (query, html ("Logout")));
         }
     }
   else
     html_list_append (menu, "User accounts not enabled on this server<br/>");
 
   return html (
+               "TODO: webgit logo <br />",
                menu, "<br />",
                webgit_main_link (query, html ("Main")), "<br />"
                );
@@ -302,7 +290,7 @@ webgit_account_content_action (struct webgit_query* query)
     {
       if (!query->user)
         {
-          /* create account or recover */
+          /* create account */
           html_list_append (content,
                             "TODO: Explain account creation, cookies etc...",
                             html (
@@ -314,6 +302,12 @@ webgit_account_content_action (struct webgit_query* query)
                                   "Username: (2-32 lowercase ascii chars)<br/>",
                                   html (
                                         html_tag ("input", html_attr ("name", "user"))
+                                        ),
+                                  html (
+                                        html_tag ("input",
+                                                  html_attr ("name", "recover"),
+                                                  html_attr ("type", "submit"),
+                                                  html_attr ("value", "Recover Account"))
                                         ), "<br/>",
                                   "Real Name: (must contain at least one space, utf8)<br/>",
                                   html (
@@ -325,8 +319,9 @@ webgit_account_content_action (struct webgit_query* query)
                                         ), "<br/>",
                                   html (
                                         html_tag ("input",
+                                                  html_attr ("name", "create"),
                                                   html_attr ("type", "submit"),
-                                                  html_attr ("value", "Create Account.."))
+                                                  html_attr ("value", "Create Account"))
                                         )
                                   )
                             );
@@ -338,45 +333,32 @@ webgit_account_content_action (struct webgit_query* query)
               /* create 2nd step, must not exist send signed cookie */
               if (!webgit_account_user_validate (query->user))
                 die ("invalid user name");
-              if (!webgit_account_name_validate (query->name))
-                die ("invalid name");
-              if (!webgit_account_email_validate (query->email))
-                die ("invalid email");
 
-              webgit_account_create_pending (query);
+              if (query->recover)
+                {
+                  webgit_account_recover (query);
 
-              html_list_append (content, "account created, email send");
+                  html_list_append (content, "account recovered, email send");
+                }
+              else
+                {
+                  if (!webgit_account_name_validate (query->name))
+                    die ("invalid name");
+                  if (!webgit_account_email_validate (query->email))
+                    die ("invalid email");
 
+                  webgit_account_create_pending (query);
+
+                  html_list_append (content, "account created, email send");
+                }
             }
           else
             {
               /* change name/email */
-              //free (query->login_cookie);
-              //query->login_cookie = cwa_strndup ("", SIZE_MAX);
-              //query->cookie_expire = 0;
 
               html_list_append (content,
-                                html (
-                                      html_tag ("a",
-                                                html_attr ("href",
-                                                           html(
-                                                                html_str (query->request->script_name),
-                                                                "?expire=0"
-                                                                )
-                                                           )
-                                                ),
-                                      "Deactivate&nbsp;Account"
-                                      ), "<br />",
-
-
-
-
-                                "Delete&nbsp;Account", "<br />"
-
+                                "TODO: preferences"
                                 );
-
-
-
             }
         }
     }
index f61a73a..0a06404 100644 (file)
@@ -59,6 +59,7 @@ webgit_query_init (struct webgit_query* q)
   q->name = NULL;
   q->email = NULL;
   q->ssign = NULL;
+  q->recover = 0;
   q->skin = cwa_strndup (WEBGIT_DEFAULT_SKIN, SIZE_MAX);
   q->count = -1;
 
@@ -322,6 +323,16 @@ webgit_ssign_param (const Cgi self, const char* v, size_t v_sz, void* u_dat)
 }
 
 
+static void
+webgit_recover_param (const Cgi self, const char* v, size_t v_sz, void* u_dat)
+{
+  (void) self;
+  struct webgit_query* q = (struct webgit_query*) u_dat;
+
+  q->recover = 1;
+}
+
+
 static void
 webgit_login_param (const Cgi self, const char* v, size_t v_sz, void* u_dat)
 {
index afdcddd..e21c8a0 100644 (file)
@@ -40,6 +40,7 @@
  WEBGIT_PARAM(email, "Email of the editing user")                       \
  WEBGIT_PARAM(ssign, "Server signature over user/name/email")           \
  WEBGIT_PARAM(expire, "Cookie expire time in days")                     \
+ WEBGIT_PARAM(recover, "Email login token to user")                     \
  WEBGIT_PARAM(skin, "Set skin")                                         \
  WEBGIT_PARAM(maxage, "Age in days to hide inactive repositories")      \
  WEBGIT_PARAM(login, "Login cookie")                                    \
index d482d89..e42ee1f 100644 (file)
@@ -75,6 +75,7 @@ struct webgit_query
   char* name;
   char* email;
   char* ssign;
+  int recover;
   char* skin;
   int count;