* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
- $cookie = $this->tryCookie();
- if ($cookie == 0) {
- return $this->start(AUTH_COOKIE);
- } else if ($cookie == 1 || $cookie == -2) {
+ switch ($this->tryCookie()) {
+ case self::COOKIE_SUCCESS:
+ if (!$this->start(AUTH_COOKIE)) {
+ return false;
+ }
+ break;
+
+ case self::INVALID_USER:
+ case self::INVALID_COOKIE:
Cookie::i('uid'));
if ($res->numRows() != 0) {
list($uid, $password) = $res->fetchOneRow();
Cookie::i('uid'));
if ($res->numRows() != 0) {
list($uid, $password) = $res->fetchOneRow();
}
private function checkPassword($uname, $login, $response, $login_type)
}
private function checkPassword($uname, $login, $response, $login_type)
$res = XDB::query("SELECT a.uid, a.hruid, a.display_name, a.full_name,
a.sex = 'female' AS femme, a.email_format,
a.token, FIND_IN_SET('watch', a.flags) AS watch_account,
$res = XDB::query("SELECT a.uid, a.hruid, a.display_name, a.full_name,
a.sex = 'female' AS femme, a.email_format,
a.token, FIND_IN_SET('watch', a.flags) AS watch_account,
a.last_version, g.g_account_name IS NOT NULL AS googleapps,
UNIX_TIMESTAMP(s.start) AS lastlogin, s.host,
a.is_admin, at.perms
a.last_version, g.g_account_name IS NOT NULL AS googleapps,
UNIX_TIMESTAMP(s.start) AS lastlogin, s.host,
a.is_admin, at.perms
LEFT JOIN logger.last_sessions AS ls ON (ls.uid = a.uid)
LEFT JOIN logger.sessions AS s ON(s.id = ls.id)
WHERE a.uid = {?} AND a.state = 'active'", $user->id());
LEFT JOIN logger.last_sessions AS ls ON (ls.uid = a.uid)
LEFT JOIN logger.sessions AS s ON(s.id = ls.id)
WHERE a.uid = {?} AND a.state = 'active'", $user->id());
- $n = select_notifs(false, S::i('uid'), S::v('watch_last'), false);
- S::set('notifs', $n->numRows());
+ $user = S::user();
+ $n = Watch::getCount($user);
+ S::set('notifs', $n);
}
public function setAccessCookie($replace = false, $log = true) {
if (S::suid() || ($replace && !Cookie::blank('access'))) {
return;
}
}
public function setAccessCookie($replace = false, $log = true) {
if (S::suid() || ($replace && !Cookie::blank('access'))) {
return;
}
- Cookie::set('access', sha1(S::v('password')), 300, true);
+ Cookie::set('access', sha1(S::user()->password()), 300, true);