Now logging in with Red zaccount/zentity instead of Friendica user. Yay. Most existing Friendica functionality is now stuffed since the Red structures are quite different.
This commit is contained in:
parent
8c3c3d5fd7
commit
7fad83cea4
@ -32,8 +32,7 @@ link if your cert is self-signed).
|
|||||||
- Apache with mod-rewrite enabled and "Options All" so you can use a
|
- Apache with mod-rewrite enabled and "Options All" so you can use a
|
||||||
local .htaccess file
|
local .htaccess file
|
||||||
|
|
||||||
- PHP 5.3+. The later the better. PHP 5.3 is required for communications
|
- PHP 5.3+. The later the better.
|
||||||
with the Diaspora network and improved security.
|
|
||||||
|
|
||||||
- PHP *command line* access with register_argc_argv set to true in the
|
- PHP *command line* access with register_argc_argv set to true in the
|
||||||
php.ini file [or see 'poormancron' in section 8]
|
php.ini file [or see 'poormancron' in section 8]
|
||||||
|
@ -227,7 +227,7 @@ CREATE TABLE IF NOT EXISTS `entity` (
|
|||||||
`entity_name` char(255) NOT NULL DEFAULT '',
|
`entity_name` char(255) NOT NULL DEFAULT '',
|
||||||
`entity_address` char(255) NOT NULL DEFAULT '',
|
`entity_address` char(255) NOT NULL DEFAULT '',
|
||||||
`entity_global_id` char(255) NOT NULL DEFAULT '',
|
`entity_global_id` char(255) NOT NULL DEFAULT '',
|
||||||
`entity_timezone` char(128) NOT NULL DEFAULT '',
|
`entity_timezone` char(128) NOT NULL DEFAULT 'UTC',
|
||||||
`entity_location` char(255) NOT NULL DEFAULT '',
|
`entity_location` char(255) NOT NULL DEFAULT '',
|
||||||
`entity_theme` char(255) NOT NULL DEFAULT '',
|
`entity_theme` char(255) NOT NULL DEFAULT '',
|
||||||
`entity_pubkey` text NOT NULL,
|
`entity_pubkey` text NOT NULL,
|
||||||
|
@ -91,6 +91,10 @@ function create_account($arr) {
|
|||||||
$parent = ((x($arr,'parent')) ? intval($arr['parent']) : 0 );
|
$parent = ((x($arr,'parent')) ? intval($arr['parent']) : 0 );
|
||||||
$flags = ((x($arr,'account_flags')) ? intval($arr['account_flags']) : ACCOUNT_OK);
|
$flags = ((x($arr,'account_flags')) ? intval($arr['account_flags']) : ACCOUNT_OK);
|
||||||
|
|
||||||
|
$default_service_class = get_config('system','default_service_class');
|
||||||
|
if($default_service_class === false)
|
||||||
|
$default_service_class = '';
|
||||||
|
|
||||||
if((! x($email)) || (! x($password))) {
|
if((! x($email)) || (! x($password))) {
|
||||||
$result['message'] = t('Please enter the required information.');
|
$result['message'] = t('Please enter the required information.');
|
||||||
return $result;
|
return $result;
|
||||||
@ -236,7 +240,7 @@ function send_reg_approval_email($arr) {
|
|||||||
function send_verification_email($email,$password) {
|
function send_verification_email($email,$password) {
|
||||||
|
|
||||||
$email_msg = replace_macros(get_intltext_template('register_open_eml.tpl'), array(
|
$email_msg = replace_macros(get_intltext_template('register_open_eml.tpl'), array(
|
||||||
'$sitename' => $get_config('config','sitename'),
|
'$sitename' => get_config('config','sitename'),
|
||||||
'$siteurl' => z_root(),
|
'$siteurl' => z_root(),
|
||||||
'$email' => $email,
|
'$email' => $email,
|
||||||
'$password' => $password,
|
'$password' => $password,
|
||||||
|
@ -5,6 +5,7 @@ require_once('include/security.php');
|
|||||||
|
|
||||||
function nuke_session() {
|
function nuke_session() {
|
||||||
unset($_SESSION['authenticated']);
|
unset($_SESSION['authenticated']);
|
||||||
|
unset($_SESSION['account_id']);
|
||||||
unset($_SESSION['uid']);
|
unset($_SESSION['uid']);
|
||||||
unset($_SESSION['visitor_id']);
|
unset($_SESSION['visitor_id']);
|
||||||
unset($_SESSION['administrator']);
|
unset($_SESSION['administrator']);
|
||||||
@ -70,7 +71,7 @@ if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(x($_SESSION,'uid')) {
|
if(x($_SESSION,'uid') || x($_SESSION,'account_id')) {
|
||||||
|
|
||||||
// already logged in user returning
|
// already logged in user returning
|
||||||
|
|
||||||
@ -83,18 +84,27 @@ if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-p
|
|||||||
goaway(z_root());
|
goaway(z_root());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(x($_SESSION,'account_id')) {
|
||||||
$r = q("select * from account where account_id = %d limit 1",
|
$r = q("select * from account where account_id = %d limit 1",
|
||||||
intval($_SESSION['account_id'])
|
intval($_SESSION['account_id'])
|
||||||
);
|
);
|
||||||
if(count($r) && (($r[0]['account_flags'] == ACCOUNT_OK) || ($r[0]['account_flags'] == ACCOUNT_UNVERIFIED)))
|
if(count($r) && (($r[0]['account_flags'] == ACCOUNT_OK) || ($r[0]['account_flags'] == ACCOUNT_UNVERIFIED))) {
|
||||||
get_app()->account = $r[0];
|
get_app()->account = $r[0];
|
||||||
else
|
authenticate_success($r[0]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
$_SESSION['account_id'] = 0;
|
$_SESSION['account_id'] = 0;
|
||||||
|
nuke_session();
|
||||||
|
goaway(z_root());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
$r = q("SELECT `user`.*, `user`.`pubkey` as `upubkey`, `user`.`prvkey` as `uprvkey`
|
$r = q("SELECT `user`.*, `user`.`pubkey` as `upubkey`, `user`.`prvkey` as `uprvkey`
|
||||||
FROM `user` WHERE `uid` = %d AND `blocked` = 0 AND `account_expired` = 0 AND `verified` = 1 LIMIT 1",
|
FROM `user` WHERE `uid` = %d AND `blocked` = 0
|
||||||
|
AND `account_expired` = 0 AND `verified` = 1 LIMIT 1",
|
||||||
intval($_SESSION['uid'])
|
intval($_SESSION['uid'])
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if(! count($r)) {
|
if(! count($r)) {
|
||||||
nuke_session();
|
nuke_session();
|
||||||
@ -139,7 +149,7 @@ else {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
get_app()->account = account_verify_password($_POST['username'],$_POST['password']);
|
$record = get_app()->account = account_verify_password($_POST['username'],$_POST['password']);
|
||||||
|
|
||||||
if(get_app()->account) {
|
if(get_app()->account) {
|
||||||
$_SESSION['account_id'] = get_app()->account['account_id'];
|
$_SESSION['account_id'] = get_app()->account['account_id'];
|
||||||
@ -153,15 +163,15 @@ else {
|
|||||||
|
|
||||||
// process normal login request
|
// process normal login request
|
||||||
|
|
||||||
$r = q("SELECT `user`.*, `user`.`pubkey` as `upubkey`, `user`.`prvkey` as `uprvkey`
|
// $r = q("SELECT `user`.*, `user`.`pubkey` as `upubkey`, `user`.`prvkey` as `uprvkey`
|
||||||
FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' )
|
// FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' )
|
||||||
AND `password` = '%s' AND `blocked` = 0 AND `account_expired` = 0 AND `verified` = 1 LIMIT 1",
|
// AND `password` = '%s' AND `blocked` = 0 AND `account_expired` = 0 AND `verified` = 1 LIMIT 1",
|
||||||
dbesc(trim($_POST['username'])),
|
// dbesc(trim($_POST['username'])),
|
||||||
dbesc(trim($_POST['username'])),
|
// dbesc(trim($_POST['username'])),
|
||||||
dbesc($encrypted)
|
// dbesc($encrypted)
|
||||||
);
|
// );
|
||||||
if(count($r))
|
// if(count($r))
|
||||||
$record = $r[0];
|
// $record = $r[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if((! $record) || (! count($record))) {
|
if((! $record) || (! count($record))) {
|
||||||
|
@ -8,6 +8,7 @@ function js_strings() {
|
|||||||
'$showfewer' => t('show fewer'),
|
'$showfewer' => t('show fewer'),
|
||||||
'$pwshort' => t("Password too short"),
|
'$pwshort' => t("Password too short"),
|
||||||
'$pwnomatch' => t("Passwords do not match"),
|
'$pwnomatch' => t("Passwords do not match"),
|
||||||
|
'$everybody' => t('everybody'),
|
||||||
|
|
||||||
'$t01' => ((t('timeago.prefixAgo') != 'timeago.prefixAgo') ? t('timeago.prefixAgo') : 'null'),
|
'$t01' => ((t('timeago.prefixAgo') != 'timeago.prefixAgo') ? t('timeago.prefixAgo') : 'null'),
|
||||||
'$t02' => ((t('timeago.suffixAgo') != 'timeago.suffixAgo') ? t('timeago.suffixAgo') : 'null'),
|
'$t02' => ((t('timeago.suffixAgo') != 'timeago.suffixAgo') ? t('timeago.suffixAgo') : 'null'),
|
||||||
|
@ -1,16 +1,57 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
function authenticate_success($user_record, $login_initial = false, $interactive = false) {
|
function authenticate_success($user_record, $login_initial = false, $interactive = false,$return = false) {
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
|
$_SESSION['addr'] = $_SERVER['REMOTE_ADDR'];
|
||||||
|
|
||||||
|
// logger('authenticate_success: ' . print_r($user_record,true));
|
||||||
|
// logger('authenticate_success: ' . print_r($_SESSION,true));
|
||||||
|
|
||||||
|
if(x($user_record,'account_id')) {
|
||||||
|
logger('authenticate_success: Red-style');
|
||||||
|
$a->account = $user_record;
|
||||||
|
$_SESSION['account_id'] = $a->account['account_id'];
|
||||||
|
$_SESSION['authenticated'] = 1;
|
||||||
|
|
||||||
|
if($login_initial) {
|
||||||
|
q("update account set account_lastlog = '%s' where account_id = %d limit 1",
|
||||||
|
dbesc(datetime_convert()),
|
||||||
|
intval($_SESSION['account_id'])
|
||||||
|
);
|
||||||
|
$a->account['account_lastlog'] = datetime_convert();
|
||||||
|
call_hooks('logged_in', $a->account);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$uid_to_load = (((x($_SESSION,'uid')) && (intval($_SESSION['uid']))) ? intval($_SESSION['uid']) : 0);
|
||||||
|
if(! $uid_to_load)
|
||||||
|
$uid_to_load = intval($a->account['account_default_entity']);
|
||||||
|
|
||||||
|
if($uid_to_load) {
|
||||||
|
$r = q("select * from entity where entity_id = %d and entity_account_id = %d limit 1",
|
||||||
|
intval($uid_to_load),
|
||||||
|
intval($a->account['account_id'])
|
||||||
|
);
|
||||||
|
if($r && count($r)) {
|
||||||
|
$_SESSION['uid'] = intval($r[0]['entity_id']);
|
||||||
|
$a->identity = $r[0];
|
||||||
|
$_SESSION['theme'] = $a->identity['entity_theme'];
|
||||||
|
date_default_timezone_set($a->identity['entity_timezone']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
$_SESSION['uid'] = $user_record['uid'];
|
$_SESSION['uid'] = $user_record['uid'];
|
||||||
$_SESSION['theme'] = $user_record['theme'];
|
$_SESSION['theme'] = $user_record['theme'];
|
||||||
$_SESSION['authenticated'] = 1;
|
$_SESSION['authenticated'] = 1;
|
||||||
$_SESSION['page_flags'] = $user_record['page-flags'];
|
$_SESSION['page_flags'] = $user_record['page-flags'];
|
||||||
$_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $user_record['nickname'];
|
$_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $user_record['nickname'];
|
||||||
$_SESSION['my_address'] = $user_record['nickname'] . '@' . substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3);
|
$_SESSION['my_address'] = $user_record['nickname'] . '@' . substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3);
|
||||||
$_SESSION['addr'] = $_SERVER['REMOTE_ADDR'];
|
|
||||||
|
|
||||||
$a->user = $user_record;
|
$a->user = $user_record;
|
||||||
|
|
||||||
@ -86,9 +127,20 @@ function authenticate_success($user_record, $login_initial = false, $interactive
|
|||||||
|
|
||||||
call_hooks('logged_in', $a->user);
|
call_hooks('logged_in', $a->user);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if($return || $_SESSION['workflow']) {
|
||||||
|
unset($_SESSION['workflow']);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(($a->module !== 'home') && isset($_SESSION['return_url']))
|
if(($a->module !== 'home') && isset($_SESSION['return_url']))
|
||||||
goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
|
goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,35 +16,6 @@ function get_theme_config_file($theme){
|
|||||||
|
|
||||||
function settings_init(&$a) {
|
function settings_init(&$a) {
|
||||||
|
|
||||||
// These lines provide the javascript needed by the acl selector
|
|
||||||
|
|
||||||
$a->page['htmlhead'] .= "<script> var ispublic = '" . t('everybody') . "';" ;
|
|
||||||
|
|
||||||
$a->page['htmlhead'] .= <<< EOT
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
|
|
||||||
$('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
|
|
||||||
var selstr;
|
|
||||||
$('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
|
|
||||||
selstr = $(this).text();
|
|
||||||
$('#jot-perms-icon').removeClass('unlock').addClass('lock');
|
|
||||||
$('#jot-public').hide();
|
|
||||||
});
|
|
||||||
if(selstr == null) {
|
|
||||||
$('#jot-perms-icon').removeClass('lock').addClass('unlock');
|
|
||||||
$('#jot-public').show();
|
|
||||||
}
|
|
||||||
|
|
||||||
}).trigger('change');
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
|
||||||
EOT;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$tabs = array(
|
$tabs = array(
|
||||||
array(
|
array(
|
||||||
'label' => t('Account settings'),
|
'label' => t('Account settings'),
|
||||||
@ -671,15 +642,17 @@ function settings_content(&$a) {
|
|||||||
if(count($p))
|
if(count($p))
|
||||||
$profile = $p[0];
|
$profile = $p[0];
|
||||||
|
|
||||||
$username = $a->user['username'];
|
load_pconfig(local_user(),'expire');
|
||||||
$email = $a->user['email'];
|
|
||||||
$nickname = $a->user['nickname'];
|
$username = $a->identity['entity_name'];
|
||||||
$timezone = $a->user['timezone'];
|
$email = $a->account['account_email'];
|
||||||
$notify = $a->user['notify-flags'];
|
$nickname = $a->identity['entity_address'];
|
||||||
$defloc = $a->user['default-location'];
|
$timezone = $a->identity['entity_timezone'];
|
||||||
$openid = $a->user['openid'];
|
$notify = $a->identity['entity_notifyflags'];
|
||||||
$maxreq = $a->user['maxreq'];
|
$defloc = $a->identity['entity_location'];
|
||||||
$expire = ((intval($a->user['expire'])) ? $a->user['expire'] : '');
|
|
||||||
|
$maxreq = $a->identity['entity_max_friend_req'];
|
||||||
|
$expire = get_pconfig(local_user(),'expire','content_expire_days');
|
||||||
$blockwall = $a->user['blockwall'];
|
$blockwall = $a->user['blockwall'];
|
||||||
$blocktags = $a->user['blocktags'];
|
$blocktags = $a->user['blocktags'];
|
||||||
$unkmail = $a->user['unkmail'];
|
$unkmail = $a->user['unkmail'];
|
||||||
@ -714,7 +687,6 @@ function settings_content(&$a) {
|
|||||||
$post_profilechange = (($post_profilechange===false)? '0': $post_profilechange); // default if not set: 0
|
$post_profilechange = (($post_profilechange===false)? '0': $post_profilechange); // default if not set: 0
|
||||||
|
|
||||||
|
|
||||||
if(! strlen($a->user['timezone']))
|
|
||||||
$timezone = date_default_timezone_get();
|
$timezone = date_default_timezone_get();
|
||||||
|
|
||||||
|
|
||||||
@ -744,15 +716,6 @@ function settings_content(&$a) {
|
|||||||
|
|
||||||
));
|
));
|
||||||
|
|
||||||
$noid = get_config('system','no_openid');
|
|
||||||
|
|
||||||
if($noid) {
|
|
||||||
$openid_field = false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$openid_field = array('openid_url', t('OpenID:'),$openid, t("\x28Optional\x29 Allow this OpenID to login to this account."));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$opt_tpl = get_markup_template("field_yesno.tpl");
|
$opt_tpl = get_markup_template("field_yesno.tpl");
|
||||||
if(get_config('system','publish_all')) {
|
if(get_config('system','publish_all')) {
|
||||||
|
@ -73,7 +73,11 @@ function zentity_post(&$a) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
if(! strlen($next_page = get_config('system','workflow_identity_next')))
|
||||||
|
$next_page = 'settings';
|
||||||
|
|
||||||
|
goaway(z_root() . '/' . $next_page);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,7 +75,6 @@ function zregister_post(&$a) {
|
|||||||
}
|
}
|
||||||
require_once('include/security.php');
|
require_once('include/security.php');
|
||||||
|
|
||||||
authenticate_success($result['account'],true,true);
|
|
||||||
|
|
||||||
$using_invites = intval(get_config('system','invitation_only'));
|
$using_invites = intval(get_config('system','invitation_only'));
|
||||||
$num_invites = intval(get_config('system','number_invites'));
|
$num_invites = intval(get_config('system','number_invites'));
|
||||||
@ -90,7 +89,6 @@ function zregister_post(&$a) {
|
|||||||
$res = send_verification_email($result['email'],$result['password']);
|
$res = send_verification_email($result['email'],$result['password']);
|
||||||
if($res) {
|
if($res) {
|
||||||
info( t('Registration successful. Please check your email for validation instructions.') . EOL ) ;
|
info( t('Registration successful. Please check your email for validation instructions.') . EOL ) ;
|
||||||
goaway(z_root());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif($policy == REGISTER_APPROVE) {
|
elseif($policy == REGISTER_APPROVE) {
|
||||||
@ -103,7 +101,16 @@ function zregister_post(&$a) {
|
|||||||
}
|
}
|
||||||
goaway(z_root());
|
goaway(z_root());
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
|
authenticate_success($result['account'],true,false,true);
|
||||||
|
|
||||||
|
if(! strlen($next_page = get_config('system','workflow_register_next')))
|
||||||
|
$next_page = 'zentity';
|
||||||
|
|
||||||
|
$_SESSION['workflow'] = true;
|
||||||
|
|
||||||
|
goaway(z_root() . '/' . $next_page);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
2012-08-26.58
|
2012-08-27.59
|
||||||
|
21
view/js/mod_settings.js
Normal file
21
view/js/mod_settings.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
var ispublic = aStr['everybody'] ;
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
$('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
|
||||||
|
var selstr;
|
||||||
|
$('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
|
||||||
|
selstr = $(this).text();
|
||||||
|
$('#jot-perms-icon').removeClass('unlock').addClass('lock');
|
||||||
|
$('#jot-public').hide();
|
||||||
|
});
|
||||||
|
if(selstr == null) {
|
||||||
|
$('#jot-perms-icon').removeClass('lock').addClass('unlock');
|
||||||
|
$('#jot-public').show();
|
||||||
|
}
|
||||||
|
|
||||||
|
}).trigger('change');
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -9,6 +9,7 @@
|
|||||||
'showfewer' : '$showfewer',
|
'showfewer' : '$showfewer',
|
||||||
'pwshort' : '$pwshort',
|
'pwshort' : '$pwshort',
|
||||||
'pwnomatch' : '$pwnomatch',
|
'pwnomatch' : '$pwnomatch',
|
||||||
|
'everybody' : '$everybody',
|
||||||
|
|
||||||
't01' : $t01,
|
't01' : $t01,
|
||||||
't02' : $t02,
|
't02' : $t02,
|
||||||
|
@ -10,9 +10,6 @@ $nickname_block
|
|||||||
{{inc field_password.tpl with $field=$password1 }}{{endinc}}
|
{{inc field_password.tpl with $field=$password1 }}{{endinc}}
|
||||||
{{inc field_password.tpl with $field=$password2 }}{{endinc}}
|
{{inc field_password.tpl with $field=$password2 }}{{endinc}}
|
||||||
|
|
||||||
{{ if $oid_enable }}
|
|
||||||
{{inc field_input.tpl with $field=$openid }}{{endinc}}
|
|
||||||
{{ endif }}
|
|
||||||
|
|
||||||
<div class="settings-submit-wrapper" >
|
<div class="settings-submit-wrapper" >
|
||||||
<input type="submit" name="submit" class="settings-submit" value="$submit" />
|
<input type="submit" name="submit" class="settings-submit" value="$submit" />
|
||||||
|
Reference in New Issue
Block a user