taskrambler  0.1.9
Web server and task management solution.
application/controller/authenticate/create.c File Reference
#include "class.h"
#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/authenticate/create.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 

Functions

char * controllerCurrentuserRead (Application, Session, Hash)
 
char * controllerAuthenticateCreate (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/authenticate/create.c.

Macro Definition Documentation

#define _GNU_SOURCE

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

Function Documentation

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

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

References applicationLogin(), controllerCurrentuserRead(), CRED_PASSWORD, CSTRA, and hashGet().

41 {
42  HashValue username;
43  HashValue password;
44  Credential credential;
45 
46  char * response_data;
47 
48  username = hashGet(args, CSTRA("username"));
49  password = hashGet(args, CSTRA("password"));
50 
51  if (NULL == username) {
52  username = hashGet(args, CSTRA("email"));
53  }
54 
55  if (NULL == username || NULL == password) {
56  return NULL;
57  }
58 
59  credential = new(Credential,
61  (char *)(username->value), username->nvalue,
62  (char *)(password->value), password->nvalue);
63 
64  if (! applicationLogin(application, credential, session)) {
65  response_data = NULL;
66  } else {
67  response_data = controllerCurrentuserRead(application, session, NULL);
68  }
69 
70  delete(credential);
71 
72  return response_data;
73 }
char * controllerCurrentuserRead(Application, Session, Hash)
#define CSTRA(val)
Const STRing Argument.
Definition: memory.h:26
void * hashGet(Hash, const char *, size_t)
Definition: hash/get.c:51
int applicationLogin(Application, Credential, Session)
Definition: login.c:42

+ Here is the call graph for this function:

char* controllerCurrentuserRead ( Application  ,
Session  ,
Hash   
)

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

Referenced by controllerAuthenticateCreate().

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: