Esempio n. 1
0
    def create_user(app, interface, db):
        user = get_input('username: '******'user must not exist'

        password = getpass.getpass('password: '******'password is illegal'
        with app.app_context():
            interface.create_user(email=user, password=password)
            db.session.commit()
Esempio n. 2
0
 def _change_user_password(self, user_id):
     new_password = request.form['admin_change_password']
     retype_password = request.form['admin_confirm_password']
     if not new_password == retype_password:
         flash('Error: passwords do not match')
     elif not password_is_legal(new_password):
         flash('Error: password is not legal. Please choose another password.')
     else:
         user = self._user_db_interface.find_user(id=user_id)
         with self.user_db_session('Error: could not change password'):
             self._user_db_interface.change_password(user.email, new_password)
             flash('password change successful', 'success')
Esempio n. 3
0
 def _change_own_password(self):
     new_password = request.form['new_password']
     new_password_confirm = request.form['new_password_confirm']
     old_password = request.form['old_password']
     if new_password != new_password_confirm:
         flash('Error: new password did not match', 'warning')
     elif not self._user_db_interface.password_is_correct(current_user.email, old_password):
         flash('Error: wrong password', 'warning')
     elif not password_is_legal(new_password):
         flash('Error: password is not legal. Please choose another password.')
     else:
         with self.user_db_session('Error: could not change password'):
             self._user_db_interface.change_password(current_user.email, new_password)
             flash('password change successful', 'success')
Esempio n. 4
0
 def create_user(self):
     user_list = self._get_user_list()
     user = self.session.prompt(
         'username: '******'user must not exist and not be empty'),
         completer=None)
     while True:
         password = getpass.getpass('password: '******'Password is not legal. Please choose another password.')
             continue
         break
     with self.app.app_context():
         self.store.create_user(email=user,
                                password=hash_password(password),
                                roles=['guest'])
         self.db.session.commit()
Esempio n. 5
0
def test_password_is_legal(input_data, expected):
    assert password_is_legal(input_data) == expected