taskrambler  0.1.9
Web server and task management solution.
application/controller/user/create.c File Reference
#include "application/application.h"
#include "session.h"
#include "hash.h"
#include "auth/credential.h"
#include "user.h"
#include "utils/memory.h"
+ Include dependency graph for application/controller/user/create.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 

Functions

char * controllerCurrentuserRead (Application, Session, Hash)
 
int _controllerProcessUserCreateArgs (Hash, User *, Credential *)
 
char * controllerUserCreate (Application application, Session session, Hash args)
 

Detailed Description

Author
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/.

Definition in file application/controller/user/create.c.

Macro Definition Documentation

#define _GNU_SOURCE

Definition at line 23 of file application/controller/user/create.c.

Function Documentation

int _controllerProcessUserCreateArgs ( Hash  ,
User *  ,
Credential *   
)

Definition at line 36 of file _process_user_create_args.c.

References _controllerGetCredentialFromArgs(), _controllerGetUserFromArgs(), FALSE, and TRUE.

Referenced by controllerUserCreate().

37 {
38  *user = _controllerGetUserFromArgs(args);
40 
41  if (NULL == *user || NULL == *cred) {
42  delete(*user);
43  delete(*cred);
44 
45  return FALSE;
46  }
47 
48  return TRUE;
49 }
Credential _controllerGetCredentialFromArgs(Hash args)
#define FALSE
Definition: commons.h:28
#define TRUE
Definition: commons.h:27
User _controllerGetUserFromArgs(Hash args)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char* controllerCurrentuserRead ( Application  ,
Session  ,
Hash   
)

Definition at line 40 of file application/controller/currentuser/read.c.

Referenced by controllerUserCreate().

41 {
42  char * buffer;
43  size_t nbuffer;
44 
45  nbuffer = snprintf(NULL, 0, USER_JSON,
46  (NULL != sess->user)? sess->user->username : "",
47  (NULL != sess->user)? sess->user->email : "",
48  (NULL != sess->user)? sess->user->firstname : "",
49  (NULL != sess->user)? sess->user->surname : "");
50  buffer = memMalloc(nbuffer);
51  nbuffer = sprintf(buffer, USER_JSON,
52  (NULL != sess->user)? sess->user->username : "",
53  (NULL != sess->user)? sess->user->email : "",
54  (NULL != sess->user)? sess->user->firstname : "",
55  (NULL != sess->user)? sess->user->surname : "");
56 
57  return buffer;
58 }
void * memMalloc(size_t)
Definition: memory.c:783

+ Here is the caller graph for this function:

char* controllerUserCreate ( Application  application,
Session  session,
Hash  args 
)

Definition at line 37 of file application/controller/user/create.c.

References _controllerProcessUserCreateArgs(), applicationCreateUser(), controllerCurrentuserRead(), uuidCompare(), and uuidZero.

41 {
42  Credential credential;
43  User user;
44  Uuid user_id;
45  char * response_data;
46 
47  _controllerProcessUserCreateArgs(args, &user, &credential);
48 
49  user_id = applicationCreateUser(application, credential, user);
50  if (0 == uuidCompare(uuidZero, user_id)) {
51  response_data = NULL;
52  } else {
53  response_data = controllerCurrentuserRead(application, session, NULL);
54  }
55 
56  delete(credential);
57  delete(user);
58  delete(user_id);
59 
60  return response_data;
61 }
int uuidCompare(Uuid, Uuid)
Definition: compare.c:30
Uuid uuidZero
Uuid applicationCreateUser(Application, Credential, User)
Definition: create_user.c:43
int _controllerProcessUserCreateArgs(Hash, User *, Credential *)
char * controllerCurrentuserRead(Application, Session, Hash)

+ Here is the call graph for this function: