Tries to authenticate the session. @param username: the name of the user to authenticate @param password: the password for the user
(self,
session,
messages,
username,
password)
| 67 | @require(session = 'ddserver.interface.session:SessionManager', |
| 68 | messages = 'ddserver.interface.message:MessageManager') |
| 69 | def login(self, |
| 70 | session, |
| 71 | messages, |
| 72 | username, |
| 73 | password): |
| 74 | ''' Tries to authenticate the session. |
| 75 | |
| 76 | @param username: the name of the user to authenticate |
| 77 | @param password: the password for the user |
| 78 | ''' |
| 79 | |
| 80 | user = self[username] |
| 81 | |
| 82 | if not user or not pwd.verify(password, user.password): |
| 83 | messages.error('The username or password you entered was incorrect.') |
| 84 | |
| 85 | return False |
| 86 | |
| 87 | elif not user.active: |
| 88 | messages.error('This account has not yet been activated.') |
| 89 | |
| 90 | return False |
| 91 | |
| 92 | else: |
| 93 | session.username = username |
| 94 | session.save() |
| 95 | |
| 96 | messages.success('Welcome, %s' % username) |
| 97 | |
| 98 | return True |
| 99 | |
| 100 | |
| 101 |
no test coverage detected