aboutsummaryrefslogtreecommitdiffstats
path: root/include/security.php
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-07-17 21:40:04 -0700
committerredmatrix <git@macgirvin.com>2016-07-17 21:40:04 -0700
commitde4f9d68bdaade902a8030888f9df035fa1329ec (patch)
tree5021daad0c4002ce9b7c89233b7c8446552b5a07 /include/security.php
parent191cd21028ab108c2a7f982c654601d780865eff (diff)
parent571b8cc85b3a770f16aed021bb39b889e0275ed6 (diff)
downloadvolse-hubzilla-de4f9d68bdaade902a8030888f9df035fa1329ec.tar.gz
volse-hubzilla-de4f9d68bdaade902a8030888f9df035fa1329ec.tar.bz2
volse-hubzilla-de4f9d68bdaade902a8030888f9df035fa1329ec.zip
Merge branch 'dev' into perms
Diffstat (limited to 'include/security.php')
-rw-r--r--include/security.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/include/security.php b/include/security.php
index 2ab6bf075..3f31c7d9b 100644
--- a/include/security.php
+++ b/include/security.php
@@ -82,6 +82,44 @@ function authenticate_success($user_record, $login_initial = false, $interactive
/* else just return */
}
+function atoken_login($atoken) {
+ if(! $atoken)
+ return false;
+
+ $xchan = atoken_xchan($atoken);
+
+ $_SESSION['authenticated'] = 1;
+ $_SESSION['visitor_id'] = $xchan['xchan_hash'];
+ $_SESSION['atoken'] = $atoken['atoken_id'];
+
+ \App::set_observer($xchan);
+
+ return [ 'atoken' => true ];
+}
+
+
+function atoken_xchan($atoken) {
+
+ $c = channelx_by_n($atoken['atoken_uid']);
+ if($c) {
+ return [
+ 'xchan_hash' => substr($c['channel_hash'],0,16) . '.' . $atoken['atoken_name'],
+ 'xchan_name' => $atoken['atoken_name'],
+ 'xchan_addr' => t('guest:') . $atoken['atoken_name'] . '@' . \App::get_hostname(),
+ 'xchan_network' => 'unknown',
+ 'xchan_hidden' => 1,
+ 'xchan_photo_mimetype' => 'image/jpeg',
+ 'xchan_photo_l' => get_default_profile_photo(300),
+ 'xchan_photo_m' => get_default_profile_photo(80),
+ 'xchan_photo_s' => get_default_profile_photo(48)
+
+ ];
+ }
+
+}
+
+
+
/**
* @brief Change to another channel with current logged-in account.
*