1: <?php
2:
3: namespace Charcoal\User;
4:
5: // Dependency from 'charcoal-core'
6: use Charcoal\Object\ContentInterface;
7:
8: /**
9: * User Interface, based on charcoal/object/content-interface.
10: */
11: interface UserInterface extends ContentInterface
12: {
13: /**
14: * @return string
15: */
16: public static function sessionKey();
17:
18: /**
19: * Force a lowercase username
20: *
21: * @param string $username The username (also the login name).
22: * @return UserInterface Chainable
23: */
24: public function setUsername($username);
25:
26: /**
27: * The username is also used as login name and main identifier (key).
28: *
29: * @return string
30: */
31: public function username();
32:
33: /**
34: * @param string $email The user email.
35: * @return UserInterface Chainable
36: */
37: public function setEmail($email);
38:
39: /**
40: * @return string
41: */
42: public function email();
43:
44: /**
45: * @param string|null $password The user password. Encrypted in storage.
46: * @return UserInterface Chainable
47: */
48: public function setPassword($password);
49:
50: /**
51: * @return string
52: */
53: public function password();
54:
55: /**
56: * @param boolean $active The active flag.
57: * @return UserInterface Chainable
58: */
59: public function setActive($active);
60:
61: /**
62: * @return boolean
63: */
64: public function active();
65:
66: /**
67: * @param string|DateTime $ts The last login date.
68: * @return UserInterface Chainable
69: */
70: public function setLastLoginDate($ts);
71:
72: /**
73: * @return DateTime
74: */
75: public function lastLoginDate();
76:
77: /**
78: * @param string|integer|null $ip The last login IP address.
79: * @return UserInterface Chainable
80: */
81: public function setLastLoginIp($ip);
82:
83: /**
84: * Get the last login IP in x.x.x.x format
85: * @return string
86: */
87: public function lastLoginIp();
88:
89: /**
90: * @param string|DateTime $ts The last password date.
91: * @return UserInterface Chainable
92: */
93: public function setLastPasswordDate($ts);
94:
95: /**
96: * @return DateTime
97: */
98: public function lastPasswordDate();
99:
100: /**
101: * @param integer|string|null $ip The last password IP.
102: * @return UserInterface Chainable
103: */
104: public function setLastPasswordIp($ip);
105:
106: /**
107: * Get the last password change IP in x.x.x.x format.
108: *
109: * @return string
110: */
111: public function lastPasswordIp();
112:
113: /**
114: * @param string $token The login token.
115: * @return UserInterface Chainable
116: */
117: public function setLoginToken($token);
118:
119: /**
120: * @return string
121: */
122: public function loginToken();
123:
124: /**
125: * Reset the password.
126: *
127: * Encrypt the password and re-save the object in the database.
128: * Also updates the last password date & ip.
129: *
130: * @param string $plainPassword The plain (non-encrypted) password to reset to.
131: * @return UserInterface Chainable
132: */
133: public function resetPassword($plainPassword);
134: }
135: