19 changed files with 429 additions and 50 deletions
-
1Makefile.am
-
1assets/html/_menu.html
-
27assets/html/_myaccount.html
-
21assets/html/layout.html
-
12assets/js/application.js
-
13assets/js/init.js
-
20assets/js/menu.js
-
11assets/style/common.css
-
10assets/style/taskrambler.css
-
1include/application/application.h
-
7src/application/Makefile.am
-
63src/application/controller/_get_credential_from_args.c
-
54src/application/controller/_get_user_from_args.c
-
40src/application/controller/_process_user_create_args.c
-
60src/application/controller/_update_user_from_args.c
-
56src/application/controller/user/update.c
-
67src/application/update_user.c
-
4src/http/worker/process.c
-
1src/router/route.c
@ -0,0 +1,27 @@ |
|||||
|
<h4>My account</h4><div id="myaccount-close" class="link right">(close)</div> |
||||
|
<hr /> |
||||
|
<form> |
||||
|
<div class="firstname"> |
||||
|
<label for="firstname">firstname</label> |
||||
|
<input type="text" name="firstname" /><br /> |
||||
|
</div> |
||||
|
<div class="surname"> |
||||
|
<label for="surname">surname</label> |
||||
|
<input type="text" name="surname" /><br /> |
||||
|
</div> |
||||
|
<div class="email"> |
||||
|
<label for="mail">email</label> |
||||
|
<input type="text" name="email" /><br /> |
||||
|
</div> |
||||
|
<div style="height: 10px;" /> |
||||
|
<div> |
||||
|
<hr /> |
||||
|
<hr /> |
||||
|
</div> |
||||
|
<div style="height: 10px;" /> |
||||
|
<div> |
||||
|
<input type="submit" value="update account" /> |
||||
|
</div> |
||||
|
</form> |
||||
|
|
||||
|
<!-- vim: set ts=4 sw=4: --> |
||||
@ -0,0 +1,63 @@ |
|||||
|
/** |
||||
|
* \file |
||||
|
* |
||||
|
* \author Georg Hopp |
||||
|
* |
||||
|
* \copyright |
||||
|
* Copyright © 2013 Georg Hopp |
||||
|
* |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
|
*/ |
||||
|
|
||||
|
#define _GNU_SOURCE |
||||
|
|
||||
|
#include "hash.h" |
||||
|
#include "auth/credential.h" |
||||
|
|
||||
|
#include "utils/memory.h" |
||||
|
#include "commons.h" |
||||
|
|
||||
|
int _controllerValidatePasswordRepeat(char *, size_t, char *, size_t); |
||||
|
|
||||
|
Credential |
||||
|
_controllerGetCredentialFromArgs(Hash args) |
||||
|
{ |
||||
|
HashValue email = hashGet(args, CSTRA("email")); |
||||
|
HashValue password = hashGet(args, CSTRA("password")); |
||||
|
HashValue pwrepeat = hashGet(args, CSTRA("pwrepeat")); |
||||
|
|
||||
|
if ( |
||||
|
NULL == email || |
||||
|
NULL == password || |
||||
|
NULL == pwrepeat) |
||||
|
{ |
||||
|
return FALSE; |
||||
|
} |
||||
|
|
||||
|
if (! _controllerValidatePasswordRepeat( |
||||
|
password->value, |
||||
|
password->nvalue, |
||||
|
pwrepeat->value, |
||||
|
pwrepeat->nvalue)) |
||||
|
{ |
||||
|
return FALSE; |
||||
|
} |
||||
|
|
||||
|
return new(Credential, |
||||
|
CRED_PASSWORD, |
||||
|
(char *)(email->value), email->nvalue, |
||||
|
(char *)(password->value), password->nvalue); |
||||
|
} |
||||
|
|
||||
|
// vim: set ts=4 sw=4: |
||||
@ -0,0 +1,54 @@ |
|||||
|
/** |
||||
|
* \file |
||||
|
* |
||||
|
* \author Georg Hopp |
||||
|
* |
||||
|
* \copyright |
||||
|
* Copyright © 2013 Georg Hopp |
||||
|
* |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
|
*/ |
||||
|
|
||||
|
#define _GNU_SOURCE |
||||
|
|
||||
|
#include "hash.h" |
||||
|
#include "user.h" |
||||
|
|
||||
|
#include "utils/memory.h" |
||||
|
#include "commons.h" |
||||
|
|
||||
|
|
||||
|
User |
||||
|
_controllerGetUserFromArgs(Hash args) |
||||
|
{ |
||||
|
HashValue email = hashGet(args, CSTRA("email")); |
||||
|
HashValue firstname = hashGet(args, CSTRA("firstname")); |
||||
|
HashValue surname = hashGet(args, CSTRA("surname")); |
||||
|
|
||||
|
if ( |
||||
|
NULL == email || |
||||
|
NULL == firstname || |
||||
|
NULL == surname) |
||||
|
{ |
||||
|
return FALSE; |
||||
|
} |
||||
|
|
||||
|
return new(User, |
||||
|
(char *)(email->value), email->nvalue, |
||||
|
(char *)(email->value), email->nvalue, |
||||
|
(char *)(firstname->value), firstname->nvalue, |
||||
|
(char *)(surname->value), surname->nvalue); |
||||
|
} |
||||
|
|
||||
|
// vim: set ts=4 sw=4: |
||||
@ -0,0 +1,60 @@ |
|||||
|
/** |
||||
|
* \file |
||||
|
* |
||||
|
* \author Georg Hopp |
||||
|
* |
||||
|
* \copyright |
||||
|
* Copyright © 2013 Georg Hopp |
||||
|
* |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
|
*/ |
||||
|
|
||||
|
#define _GNU_SOURCE |
||||
|
|
||||
|
#include "hash.h" |
||||
|
#include "user.h" |
||||
|
|
||||
|
#include "utils/memory.h" |
||||
|
#include "commons.h" |
||||
|
|
||||
|
|
||||
|
int |
||||
|
_controllerUpdateUserFromArgs(Hash args, User * user) |
||||
|
{ |
||||
|
HashValue email = hashGet(args, CSTRA("email")); |
||||
|
HashValue firstname = hashGet(args, CSTRA("firstname")); |
||||
|
HashValue surname = hashGet(args, CSTRA("surname")); |
||||
|
User new_user; |
||||
|
|
||||
|
if ( |
||||
|
NULL == email || |
||||
|
NULL == firstname || |
||||
|
NULL == surname) |
||||
|
{ |
||||
|
return FALSE; |
||||
|
} |
||||
|
|
||||
|
new_user = new(User, |
||||
|
(char *)((*user)->username), *(*user)->nusername, |
||||
|
(char *)(email->value), email->nvalue, |
||||
|
(char *)(firstname->value), firstname->nvalue, |
||||
|
(char *)(surname->value), surname->nvalue); |
||||
|
|
||||
|
delete(*user); |
||||
|
*user = new_user; |
||||
|
|
||||
|
return TRUE; |
||||
|
} |
||||
|
|
||||
|
// vim: set ts=4 sw=4: |
||||
@ -0,0 +1,56 @@ |
|||||
|
/** |
||||
|
* \file |
||||
|
* |
||||
|
* \author Georg Hopp |
||||
|
* |
||||
|
* \copyright |
||||
|
* Copyright © 2013 Georg Hopp |
||||
|
* |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
|
*/ |
||||
|
|
||||
|
#define _GNU_SOURCE |
||||
|
|
||||
|
#include "application/application.h" |
||||
|
#include "session.h" |
||||
|
#include "hash.h" |
||||
|
#include "user.h" |
||||
|
|
||||
|
#include "utils/memory.h" |
||||
|
#include "commons.h" |
||||
|
|
||||
|
char * controllerCurrentuserRead(Application, Session, Hash); |
||||
|
int _controllerUpdateUserFromArgs(Hash, User *); |
||||
|
|
||||
|
char * |
||||
|
controllerUserUpdate( |
||||
|
Application application, |
||||
|
Session session, |
||||
|
Hash args) |
||||
|
{ |
||||
|
if (! _controllerUpdateUserFromArgs(args, &(session->user))) { |
||||
|
return NULL; |
||||
|
} |
||||
|
|
||||
|
if (0 == uuidCompare( |
||||
|
uuidZero, |
||||
|
applicationUpdateUser(application, session->user))) |
||||
|
{ |
||||
|
return NULL; |
||||
|
} |
||||
|
|
||||
|
return controllerCurrentuserRead(application, session, NULL); |
||||
|
} |
||||
|
|
||||
|
// vim: set ts=4 sw=4: |
||||
@ -0,0 +1,67 @@ |
|||||
|
/** |
||||
|
* \file |
||||
|
* |
||||
|
* \author Georg Hopp |
||||
|
* |
||||
|
* \copyright |
||||
|
* Copyright © 2013 Georg Hopp |
||||
|
* |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
|
*/ |
||||
|
|
||||
|
#define _GNU_SOURCE |
||||
|
|
||||
|
#include <stdio.h> |
||||
|
#include <stdlib.h> |
||||
|
#include <sys/types.h> |
||||
|
|
||||
|
#include "class.h" |
||||
|
#include "auth.h" |
||||
|
#include "user.h" |
||||
|
#include "uuid.h" |
||||
|
#include "storage/storage.h" |
||||
|
#include "application/application.h" |
||||
|
|
||||
|
#include "interface/serializable.h" |
||||
|
#include "interface/indexable.h" |
||||
|
|
||||
|
#include "utils/memory.h" |
||||
|
#include "commons.h" |
||||
|
|
||||
|
Uuid |
||||
|
applicationUpdateUser( |
||||
|
Application this, |
||||
|
User user) |
||||
|
{ |
||||
|
char * user_serialized; |
||||
|
size_t nuser_serialized; |
||||
|
Uuid index; |
||||
|
|
||||
|
index = indexUuid(user, this->user_namespace); |
||||
|
serialize(user, (unsigned char **)&user_serialized, &nuser_serialized); |
||||
|
|
||||
|
if (SPR_OK != storageUpdate( |
||||
|
this->users, |
||||
|
(char *)(index->uuid).value, |
||||
|
sizeof((index->uuid).value), |
||||
|
user_serialized, |
||||
|
nuser_serialized)) |
||||
|
{ |
||||
|
return uuidZero; |
||||
|
} |
||||
|
|
||||
|
return index; |
||||
|
} |
||||
|
|
||||
|
// vim: set ts=4 sw=4: |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue