__init__.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:auth-tool 作者: luciddg 项目源码 文件源码
def change(self, **params):
        engine = cherrypy.engine
        if cherrypy.session.get('auth', False):
            user = cherrypy.session['user']
            oldpasswd = cherrypy.request.params.get('oldpassword')
            newpasswd = cherrypy.request.params.get('newpassword')

            try:
                user.change_password(oldpasswd, newpasswd)

                return {'ok': True}
            except InvalidCredentials:
                return {
                    'ok': False,
                    'error': 'Current password invalid.'
                }
            except UserModelException:
                return {
                    'ok': False,
                    'error': 'Unknown system error.  Contact your Systems Administrator.'
                }

        elif cherrypy.session.get('token', False):
            cherrypy.session['user'] = User(cherrypy.session['username'])
            newpassword = cherrypy.request.params.get('newpassword')

            try:
                cherrypy.session['user'].set_password(newpassword)
                return {'ok': True}
            except UserModelException:
                return {
                    'ok': False,
                    'error': 'Unable to change your password. Try again later.'
                }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号