summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
8b4b908)
do_login() and session_startup() functions. Moved more duplicated
code into a single code path.
* Completed the OpenID signin process for existing users, and for new
users who have made their preferred nickname available via Simple
Registration Extension (assuming this nickname is available on the
Citadel system). Other sign in flows are forthcoming...
gettimeofday(&tv, NULL);
seed = tv.tv_usec;
}
gettimeofday(&tv, NULL);
seed = tv.tv_usec;
}
srandom(seed);
CtdlLogPrintf(CTDL_INFO, "Initializing ipgm secret\n");
srandom(seed);
CtdlLogPrintf(CTDL_INFO, "Initializing ipgm secret\n");
int openid_create_user_via_sri(char *claimed_id, HashList *sri_keys)
{
char *desired_name = NULL;
int openid_create_user_via_sri(char *claimed_id, HashList *sri_keys)
{
char *desired_name = NULL;
if (config.c_auth_mode != AUTHMODE_NATIVE) return(1);
if (config.c_disable_newu) return(2);
if (config.c_auth_mode != AUTHMODE_NATIVE) return(1);
if (config.c_disable_newu) return(2);
/* The desired account name is available. Create the account and log it in! */
if (create_user(desired_name, 1)) return(6);
/* The desired account name is available. Create the account and log it in! */
if (create_user(desired_name, 1)) return(6);
+ snprintf(new_password, sizeof new_password, "%08lx%08lx", random(), random());
+ CtdlSetPassword(new_password);
attach_openid(&CC->user, claimed_id);
return(0);
}
attach_openid(&CC->user, claimed_id);
return(0);
}
+// FIXME we still have to set up the vCard
// identity = [50] http://uncensored.citadel.org/~ajc/MyID.config.php
// sreg.nickname = [17] IGnatius T Foobar
// identity = [50] http://uncensored.citadel.org/~ajc/MyID.config.php
// sreg.nickname = [17] IGnatius T Foobar
cdb_free(cdboi);
if (!getuserbynumber(&CC->user, usernum)) {
cdb_free(cdboi);
if (!getuserbynumber(&CC->user, usernum)) {
+ /* Now become the user we just created */
+ safestrncpy(CC->curr_user, CC->user.fullname, sizeof CC->curr_user);
/*
* session startup code which is common to both cmd_pass() and cmd_newu()
*/
/*
* session startup code which is common to both cmd_pass() and cmd_newu()
*/
-void session_startup(void)
CtdlLogPrintf(CTDL_NOTICE, "<%s> logged in\n", CC->curr_user);
lgetuser(&CC->user, CC->curr_user);
CtdlLogPrintf(CTDL_NOTICE, "<%s> logged in\n", CC->curr_user);
lgetuser(&CC->user, CC->curr_user);
-void do_login()
-{
- (CC->logged_in) = 1;
- session_startup();
-}
-
-
int CtdlTryPassword(char *password)
{
int code;
int CtdlTryPassword(char *password)
{
int code;
/* Now become the user we just created */
memcpy(&CC->user, &usbuf, sizeof(struct ctdluser));
safestrncpy(CC->curr_user, username, sizeof CC->curr_user);
/* Now become the user we just created */
memcpy(&CC->user, &usbuf, sizeof(struct ctdluser));
safestrncpy(CC->curr_user, username, sizeof CC->curr_user);
/* Check to make sure we're still who we think we are */
if (getuser(&CC->user, CC->curr_user)) {
/* Check to make sure we're still who we think we are */
if (getuser(&CC->user, CC->curr_user)) {
a = create_user(username, 1);
if (a == 0) {
a = create_user(username, 1);
if (a == 0) {
logged_in_response();
} else if (a == ERROR + ALREADY_EXISTS) {
cprintf("%d '%s' already exists.\n",
logged_in_response();
} else if (a == ERROR + ALREADY_EXISTS) {
cprintf("%d '%s' already exists.\n",
+/*
+ * set password - back end api code
+ */
+void CtdlSetPassword(char *new_pw)
+{
+ lgetuser(&CC->user, CC->curr_user);
+ safestrncpy(CC->user.password, new_pw, sizeof(CC->user.password));
+ lputuser(&CC->user);
+ CtdlLogPrintf(CTDL_INFO, "Password changed for user <%s>\n", CC->curr_user);
+ PerformSessionHooks(EVT_SETPASS);
+}
+
+ * set password - citadel protocol implementation
*/
void cmd_setp(char *new_pw)
{
*/
void cmd_setp(char *new_pw)
{
cprintf("%d Password unchanged.\n", CIT_OK);
return;
}
cprintf("%d Password unchanged.\n", CIT_OK);
return;
}
- lgetuser(&CC->user, CC->curr_user);
- safestrncpy(CC->user.password, new_pw, sizeof(CC->user.password));
- lputuser(&CC->user);
+
+ CtdlSetPassword(new_pw);
cprintf("%d Password changed.\n", CIT_OK);
cprintf("%d Password changed.\n", CIT_OK);
- CtdlLogPrintf(CTDL_INFO, "Password changed for user <%s>\n", CC->curr_user);
- PerformSessionHooks(EVT_SETPASS);
int CtdlTryPassword(char *password);
int CtdlTryPassword(char *password);
+void CtdlSetPassword(char *new_pw);
/*
* Values which may be returned by CtdlTryPassword()
/*
* Values which may be returned by CtdlTryPassword()
serv_printf("PASS %s", bstr("pass"));
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
serv_printf("PASS %s", bstr("pass"));
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
- become_logged_in(bstr("name"),
- bstr("pass"), buf);
+ become_logged_in(bstr("name"), bstr("pass"), buf);
} else {
display_login(&buf[4]);
return;
} else {
display_login(&buf[4]);
return;
else if (linecount == 2) {
safestrncpy(password, buf, sizeof password);
}
else if (linecount == 2) {
safestrncpy(password, buf, sizeof password);
}
- else if (linecount == 2) {
+ else if (linecount == 3) {
safestrncpy(logged_in_response, buf,
sizeof logged_in_response);
}
safestrncpy(logged_in_response, buf,
sizeof logged_in_response);
}