| 221 | return self.active and not self.locked |
| 222 | |
| 223 | def is_locked(self, form_error=None): |
| 224 | # Flask-Security's LoginForm.validate() calls this after password |
| 225 | # verification and treats the return value inverted: True means |
| 226 | # "not locked, proceed"; False means "locked, fail validation". |
| 227 | # The default UserMixin.is_locked unconditionally returns True, |
| 228 | # which is what allows the /login bypass on a locked account. |
| 229 | if self.locked: |
| 230 | if form_error is not None: |
| 231 | form_error.append(gettext( |
| 232 | 'Your account is locked. Please contact the ' |
| 233 | 'Administrator.')) |
| 234 | return False |
| 235 | return True |
| 236 | |
| 237 | |
| 238 | class Setting(db.Model, UserScopedMixin): |