コード例 #1
0
    def test_set_user_password(self):
        """
        Testando a função controllers.set_user_password().
        """
        user = ut.create_user('*****@*****.**', '', True)

        controllers.set_user_password(user, '123')

        modified_user = controllers.get_user_by_id(user.id)

        self.assertTrue(check_password_hash(modified_user.password, '123'))
コード例 #2
0
ファイル: test_controller.py プロジェクト: scieloorg/opac
    def test_set_user_password(self):
        """
        Testando a função controllers.set_user_password().
        """
        user = ut.create_user('*****@*****.**', '', True)

        controllers.set_user_password(user, '123')

        modified_user = controllers.get_user_by_id(user.id)

        self.assertTrue(check_password_hash(modified_user.password, '123'))
コード例 #3
0
ファイル: views.py プロジェクト: scieloorg/opac
    def reset_with_token(self, token):
        try:
            ts = get_timed_serializer()
            email = ts.loads(token, salt="recover-key",
                             max_age=current_app.config['TOKEN_MAX_AGE'])
        except Exception as e:
            abort(404)

        form = forms.PasswordForm(request.form)
        if admin.helpers.validate_form_on_submit(form):
            user = controllers.get_user_by_email(email=email)
            if not user.email_confirmed:
                return self.render('admin/auth/unconfirm_email.html')

            controllers.set_user_password(user, form.password.data)
            flash(_('Nova senha salva com sucesso!!'))
            return redirect(url_for('.index'))

        self._template_args['form'] = form
        self._template_args['token'] = token
        return self.render('admin/auth/reset_with_token.html')
コード例 #4
0
    def reset_with_token(self, token):
        try:
            ts = get_timed_serializer()
            email = ts.loads(token,
                             salt="recover-key",
                             max_age=current_app.config['TOKEN_MAX_AGE'])
        except Exception:
            abort(404)

        form = forms.PasswordForm(request.form)
        if admin.helpers.validate_form_on_submit(form):
            user = controllers.get_user_by_email(email=email)
            if not user.email_confirmed:
                return self.render('admin/auth/unconfirm_email.html')

            controllers.set_user_password(user, form.password.data)
            flash(_('Nova senha salva com sucesso!!'))
            return redirect(url_for('.index'))

        self._template_args['form'] = form
        self._template_args['token'] = token
        return self.render('admin/auth/reset_with_token.html')