Get user profile data into $user variable
This commit is contained in:
parent
9745fe5a9f
commit
4590975b96
|
@ -45,3 +45,4 @@ function conf($key, $default='') {
|
||||||
|
|
||||||
require_once '/src/base.methods.php';
|
require_once '/src/base.methods.php';
|
||||||
require_once '/src/base.auth.php';
|
require_once '/src/base.auth.php';
|
||||||
|
require_once '/src/base.user.php';
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$user = null;
|
||||||
|
if ($valid_cookie) {
|
||||||
|
$sm = $db->prepare('SELECT id_user FROM oauth_tokens WHERE cookie = ?');
|
||||||
|
$sm->execute([$cookie]);
|
||||||
|
if (($row = $sm->fetch()) !== false) {
|
||||||
|
if (isset($row['id_user'])) {
|
||||||
|
$sm = $db->prepare('SELECT * FROM users WHERE id = ?');
|
||||||
|
$sm->execute([$row['id_user']]);
|
||||||
|
if (($user = $sm->fetchObject()) !== false) {
|
||||||
|
switch ($user->account_type)
|
||||||
|
{
|
||||||
|
case 'mastodon':
|
||||||
|
$user->account_data = json_decode($user->account_data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue