示例#1
0
def setPasswordView(tok=None):
    form = setPasswordForm()
    if form.validate_on_submit():
        dataDict={'password':form.password.data}
        req = authAPI('setPassword', method='post', dataDict=dataDict, token=tok)
        if 'error' in req:
            errorMessage(req['error'])
        elif 'success' in req:
            successMessage('Your password has now been set, please login')
            return redirect(url_for('authBP.loginView'))
    return render_template('auth/setPassword.html', form=form)
示例#2
0
def setPasswordView(lang='dk', tok=None):
    g.lang = lang
    kwargs = {'formWidth':300,
              'contentTitle':str(tok),
              'title':messageText('setPasswordTitle'),
              'breadcrumbs': breadCrumbs('authBP.setPasswordView')}

    form = setPasswordForm()

    if form.validate_on_submit():
        req = authAPI('setPassword', method='post', dataDict=dataDict, token=session['token'])
        if r.status_code == 404:
            flashMessage('userDoesNotExist')
        elif 'success' in req:
            flashMessage('passwordSet')

    return render_template(lang+'/auth/setPasswordForm.html', form=form, **kwargs)
示例#3
0
def setPasswordView(tok):
    session.clear()
    kwargs = {'formWidth': 300, 'title': 'Set new password'}

    form = setPasswordForm()

    if form.validate_on_submit():
        dataDict = {'password': form.password.data}

        req = authAPI('setPassword',
                      method='post',
                      dataDict=dataDict,
                      token=tok)

        print str(req)

        if 'error' in req:
            errorMessage(req['error'])
        elif 'success' in req:
            successMessage('Your password has now been set, please login')
            return redirect(url_for('authBP.loginView'))

    return render_template('auth/setPasswordForm.html', form=form, **kwargs)
示例#4
0
文件: views.py 项目: ThePoulsen/123
def setPasswordView(tok):
    if session['token']:
        session['token'] = None
    kwargs = {'formWidth': 300, 'title': 'Set new password'}

    form = setPasswordForm()

    if form.validate_on_submit():
        dataDict = {'password': form.password.data}
        print form.password.data
        req = authAPI('setPassword',
                      method='post',
                      dataDict=dataDict,
                      token=tok)
        if 'error' in req:
            if req['error'] == 'Could not identify access token':
                errorMessage(req['error'])

            elif req['error'] == 'Could not identify Platform':
                errorMessage(req['error'])

            elif req['error'] == 'Request data incomplete':
                errorMessage(req['error'])

            elif req['error'] == 'Illegal null values present in request data':
                errorMessage(req['error'])

            elif req['error'] == 'Invalid access token':
                errorMessage(req['error'])

            else:
                errorMessage(req['error'])
        elif 'success' in req:
            successMessage('Your password has now been set, please login')
            return redirect(url_for('authBP.loginView'))

    return render_template('auth/setPasswordForm.html', form=form, **kwargs)