Exemple #1
0
    def get(self, stub):
        forget, error = get_forget_by_stub(stub=stub)
        if error:
            return redirect(url_for('index'))

        if g.current_user:
            clear_forget(forget)
            return redirect(url_for('index'))
        return self.render_template()
Exemple #2
0
    def get(self, stub):
        forget = get_forget_by_stub(stub=stub)
        if g.current_user:
            if forget:
                forget.delete()
            return redirect(url_for('index'))

        if not forget:
            raise abort(404)

        if (datetime.now()  - forget.created).seconds > config.FORGET_STUB_EXPIRE:
            forget.delete()
            return render_template('account.reset.html', hidden=1, \
                    error=code.ACCOUNT_FORGET_STUB_EXPIRED)
        return render_template('account.reset.html', stub=stub)
Exemple #3
0
    def post(self, stub):
        forget, error = get_forget_by_stub(stub=stub)
        if error:
            return self.render_template(error=error)

        if g.current_user:
            clear_forget(forget)
            return redirect(url_for('index'))

        password = request.form.get('password', None)
        if not check_password(password):
            return self.render_template(error=code.ACCOUNT_PASSWORD_INVAILD)

        user = get_user(forget.uid)
        error = update_account(user, _forget=forget, password=password)
        if error:
            return self.render_template(error=error)
        return redirect(url_for('account.login'))
Exemple #4
0
    def post(self, stub):
        forget = get_forget_by_stub(stub=stub)
        if g.current_user:
            if forget:
                forget.delete()
            return redirect(url_for('index'))

        if not forget:
            raise abort(404)

        password = request.form.get('password', None)
        status = check_password(password)
        if status:
            return render_template('account.reset.html', stub=stub, \
                    error=status[1])
        user = get_user(forget.uid)
        user.change_password(password)
        account_login(user)
        forget.delete()
        clear_user_cache(user)
        backend.delete('account:%s' % forget.stub)
        return render_template('account.reset.html', ok=1)