1: <?php
2: /*
3: You may not change or alter any portion of this comment or credits
4: of supporting developers from this source code or any supporting source code
5: which is considered copyrighted (c) material of the original comment or credit authors.
6:
7: This program is distributed in the hope that it will be useful,
8: but WITHOUT ANY WARRANTY; without even the implied warranty of
9: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11:
12: namespace Xoops\Auth;
13:
14: use Xoops\Core\Database\Connection;
15:
16: /**
17: * Authentication class for Native XOOPS
18: *
19: * @category Xoops\Auth
20: * @package Xoops
21: * @author Pierre-Eric MENUET <pemphp@free.fr>
22: * @copyright 2000-2014 XOOPS Project (http://xoops.org)
23: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
24: * @link http://xoops.org
25: * @since 2.0
26: */
27: class Xoops extends AuthAbstract
28: {
29: /**
30: * Authentication Service constructor
31: *
32: * @param Connection|null $dao database object
33: */
34: public function __construct(Connection $dao = null)
35: {
36: $this->dao = $dao;
37: $this->auth_method = 'xoops';
38: }
39:
40: /**
41: * Authenticate user
42: *
43: * @param string $uname user name
44: * @param string $pwd password
45: *
46: * @return bool
47: */
48: public function authenticate($uname, $pwd = null)
49: {
50: $xoops = \Xoops::getInstance();
51: $member_handler = $xoops->getHandlerMember();
52: $user = false;
53: if ($member_handler) {
54: $user = $member_handler->loginUser($uname, $pwd);
55: if ($user == false) {
56: $this->setErrors(1, \XoopsLocale::E_INCORRECT_LOGIN);
57: }
58: }
59:
60: return $user;
61: }
62: }
63: