User:isActive
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
namespace Espo\Core\Utils;
|
||||
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
use \Espo\Core\Exceptions\Forbidden;
|
||||
|
||||
class Auth
|
||||
{
|
||||
@@ -72,6 +73,10 @@ class Auth
|
||||
$user = $this->authentication->login($username, $password, $authToken);
|
||||
|
||||
if ($user) {
|
||||
if (!$user->isActive()) {
|
||||
$GLOBALS['log']->debug("AUTH: Trying to login as user '".$user->get('userName')."' which is not active.");
|
||||
return false;
|
||||
}
|
||||
$entityManager->setUser($user);
|
||||
$this->container->setUser($user);
|
||||
$GLOBALS['log']->debug('AUTH: Result of authenticate is [true]');
|
||||
|
||||
@@ -18,14 +18,19 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
************************************************************************/
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Entities;
|
||||
|
||||
class User extends \Espo\Core\Entities\Person
|
||||
{
|
||||
{
|
||||
public function isAdmin()
|
||||
{
|
||||
return $this->get('isAdmin');
|
||||
}
|
||||
|
||||
public function isActive()
|
||||
{
|
||||
return $this->get('isActive');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
"passwordConfirm": "Confirm Password",
|
||||
"newPassword": "New Password",
|
||||
"newPasswordConfirm": "Confirm New Password",
|
||||
"avatar": "Avatar"
|
||||
"avatar": "Avatar",
|
||||
"isActive": "Is Active"
|
||||
},
|
||||
"links": {
|
||||
"teams": "Teams",
|
||||
@@ -36,6 +37,7 @@
|
||||
"defaultTeam": "All records created by this user will be related to this team by default.",
|
||||
"userName": "Letters a-z, numbers 0-9 and underscores are allowed.",
|
||||
"isAdmin": "Admin user can access everything.",
|
||||
"isActive": "If unchecked then user won't be able to login.",
|
||||
"teams": "Teams which this user belongs to. Access control level is inherited from team's roles.",
|
||||
"roles": "Additional access roles. Use it if user doesn't belong to any team or you need to extend access control level only for this user."
|
||||
},
|
||||
|
||||
@@ -10,8 +10,9 @@
|
||||
{
|
||||
"label": "Teams and Access Control",
|
||||
"rows": [
|
||||
[{"name":"defaultTeam"}, {"name":"isAdmin"}],
|
||||
[{"name":"teams"}, {"name":"roles"}]
|
||||
[{"name":"defaultTeam"}, {"name":"isActive"}],
|
||||
[{"name":"teams"}, {"name":"isAdmin"}],
|
||||
[{"name":"roles"}, false]
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -35,6 +35,11 @@
|
||||
"required": true,
|
||||
"default":""
|
||||
},
|
||||
"isActive": {
|
||||
"type": "bool",
|
||||
"tooltip": true,
|
||||
"default": true
|
||||
},
|
||||
"title": {
|
||||
"type": "varchar",
|
||||
"maxLength": 100
|
||||
|
||||
@@ -135,7 +135,7 @@ class User extends Record
|
||||
|
||||
$dt = new \DateTime();
|
||||
$dt->add(new \DateInterval('PT'. self::PASSWORD_CHANGE_REQUEST_LIFETIME . 'M'));
|
||||
|
||||
|
||||
$job = $this->getEntityManager()->getEntity('Job');
|
||||
|
||||
$job->set(array(
|
||||
@@ -200,6 +200,10 @@ class User extends Record
|
||||
$newPassword = $data['password'];
|
||||
$data['password'] = $this->hashPassword($data['password']);
|
||||
}
|
||||
|
||||
if ($id == $this->getUser()->id) {
|
||||
unset($data['isActive']);
|
||||
}
|
||||
$user = parent::updateEntity($id, $data);
|
||||
|
||||
if (!is_null($newPassword)) {
|
||||
|
||||
Reference in New Issue
Block a user