当前位置: 首页>>代码示例>>Python>>正文


Python User.setPass方法代码示例

本文整理汇总了Python中users.User.setPass方法的典型用法代码示例。如果您正苦于以下问题:Python User.setPass方法的具体用法?Python User.setPass怎么用?Python User.setPass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在users.User的用法示例。


在下文中一共展示了User.setPass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: userpref_page

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import setPass [as 别名]
def userpref_page():
  ''' Dashbaord User Preferences: This will allow a user to change user preferences, i.e. Password '''
  verify = verifyLogin(app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
  if verify:
    user = User()
    user.get('uid', verify, g.rdb_conn)
    data = startData(user)
    data['active'] = 'dashboard'
    if user.status != "active":
      data['url'] = '/dashboard/mod-subscription'
      tmpl = 'mod-subscription.html'
    else:
      
      ## Start processing the change password form
      form = ChangePassForm(request.form)
      if request.method == 'POST':
        if form.validate():
          result = user.setPass(form.password.data, g.rdb_conn)
          if result:
            data['msg'] = "Password successfully changed"
            print("/dashboard/user-preferences - Password changed")
            data['error'] = False
          else:
            data['msg'] = "Password change was unsuccessful"
            print("/dashboard/user-preferences - Password change failed")
            data['error'] = True
      data['url'] = '/dashboard/user-preferences'
      tmpl = 'user-preferences.html'
    page = render_template(tmpl, data=data, form=form)
    return page
  else:
    return redirect(url_for('login_page'))
开发者ID:mose,项目名称:cloudroutes-service,代码行数:34,代码来源:web.py

示例2: userpref_page

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import setPass [as 别名]
def userpref_page():
    '''
    Dashbaord User Preferences:
    This will allow a user to change user preferences, i.e. Password
    '''
    verify = verifyLogin(
        app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
    if verify:
        user = User()
        user.config = app.config
        user.get('uid', verify, g.rdb_conn)
        data = startData(user)
        data['active'] = 'dashboard'
        if user.status != "active":
            data['url'] = '/dashboard/mod-subscription'
            tmpl = 'member/mod-subscription.html'
        else:
            # Start processing the change password form
            form = ChangePassForm(request.form)
            if request.method == 'POST':
                if form.validate():
                    result = user.checkPass(form.old_password.data, g.rdb_conn)
                    if result:
                        update = user.setPass(form.password.data, g.rdb_conn)
                        if update:
                            print("/dashboard/user-preferences - Password changed")
                            flash('Password successfully changed.', 'success')
                        else:
                            print("/dashboard/user-preferences - \
                                  Password change failed")
                            flash('Password change was unsuccessful.', 'danger')
                    else:
                        print("/login - User change password error: wrong old password")
                        flash('Old password does not seem valid.', 'danger')
            data['url'] = '/dashboard/user-preferences'
            tmpl = 'member/user-preferences.html'
        page = render_template(tmpl, data=data, form=form)
        return page
    else:
        flash('Please Login.', 'warning')
        return redirect(url_for('user.login_page'))
开发者ID:madflojo,项目名称:cloudroutes-service,代码行数:43,代码来源:views.py


注:本文中的users.User.setPass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。