Completed
Push — master ( b99700...ceccd5 )
by Jean-Christophe
01:32
created

AuthControllerOverrideTrait::_connect()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
nc 1
1
<?php
2
3
namespace Ubiquity\controllers\auth;
4
5
use Ubiquity\cache\ClassUtils;
6
use Ubiquity\utils\http\USession;
7
8
trait AuthControllerOverrideTrait {
9
	
10
	abstract public function badLogin();
11
	
12
	/**
13
	 * To override
14
	 * Return the base route for this Auth controller
15
	 * @return string
16
	 */
17
	public function _getBaseRoute(){
18
		return ClassUtils::getClassSimpleName(get_class($this));
19
	}
20
	
21
	/**
22
	 * Processes the data posted by the login form
23
	 * Have to return the connected user instance
24
	 */
25
	abstract protected function _connect();
26
	
27
	/**
28
	 * @param object $connected
29
	 */
30
	abstract protected function onConnect($connected);
31
	
32
	/**
33
	 * To override for defining a new action when creditentials are invalid
34
	 */
35
	protected function onBadCreditentials(){
36
		$this->badLogin();
37
	}
38
	
39
	/**
40
	 * To override for defining user session key, default : "activeUser"
41
	 * @return string
42
	 */
43
	public function _getUserSessionKey(){
44
		return "activeUser";
45
	}
46
	
47
	/**
48
	 * To override for getting active user, default : USession::get("activeUser")
49
	 * @return string
50
	 */
51
	public function _getActiveUser(){
52
		return USession::get($this->_getUserSessionKey());
53
	}
54
	
55
	/**
56
	 * return boolean true if activeUser is valid
57
	 */
58
	abstract public function _isValidUser();
59
	
60
	/**
61
	 * Returns the value from connected user to save it in the cookie for auto connection
62
	 * @param object $connected
63
	 */
64
	protected function toCookie($connected){
65
		return;
66
	}
67
	
68
	/**
69
	 * Loads the user from database using the cookie value
70
	 * @param string $cookie
71
	 */
72
	protected function fromCookie($cookie){
73
		return;
74
	}
75
}
76
77