Beispiel #1
0
    def post(self):
        user = g.current_user
        username = request.form.get('name', None)
        password = request.form.get('password', None)
        domain = request.form.get('domain', None)

        if username != user.name:
            status = check_username(username)
            if status:
                return render_template('account.setting.html', error=status[1])
            user.change_username(username)

        if domain and not user.domain:
            for status in [check_domain(domain), check_domain_exists(domain)]:
                if status:
                    return render_template('account.setting.html', error=status[1])
            user.set_domain(domain)

        if password:
            status = check_password(password)
            if status:
                return render_template('account.setting.html', error=status[1])
            user.change_password(password)
        #clear cache
        clear_user_cache(user)
        account_login(user)
        g.current_user = get_current_user()
        return render_template('account.setting.html', error=code.ACCOUNT_SETTING_SUCCESS)
Beispiel #2
0
    def post(self):
        user = g.current_user
        password = request.form.get('password', None)
        display = request.form.get('display', None)
        city = request.form.get('city', '')
        title = request.form.get('title', '')

        attrs = {}

        if display != user.display:
            status = check_display(display)
            if not status:
                return self.render_template(
                    error=code.ACCOUNT_USERNAME_INVAILD)
            attrs['display'] = display

        if password:
            status = check_password(password)
            if not status:
                return self.render_template(
                    error=code.ACCOUNT_PASSWORD_INVAILD)
            attrs['password'] = password

        attrs['city'] = city
        attrs['title'] = title

        error = update_account(user, **attrs)
        if error:
            return self.render_template(error=error)

        #relogin
        account_login(user)
        g.current_user = get_current_user()
        return self.render_template(error=code.ACCOUNT_SETTING_SUCCESS)
Beispiel #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'))
Beispiel #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)