def modify_post(self, current_uid = -1): user_id = current_uid usr = user.get_user(user_id)[1] data = web.input(profile_image = {}) if data.newpass1 and not user.verify_password(user_id, data.oldpass): return util.render().error(error_message=_('INVALID_PASSWORD'), help_context='error') if data.newpass1 != data.newpass2: return util.render().error(error_message = _('PASSWORD_DO_NOT_MATCH'), help_context='error') if len(data.newpass1) > 0 and len(data.newpass1) < 6: return util.render().error(error_message = _('PASSWORD_TOO_SHORT'), help_context='error') if len(data.newpass1) == 0: password = data.oldpass else: password = data.newpass1 nick = data.nick email = data.email homepage = data.homepage sig = data.sig introduction = data.introduction language = data.language theme = data.theme user_info = user.get_user(user_id) change_lang = False if language != user_info[1].language: change_lang = True profile_image = data.profile_image.value delete_profile_image = data.has_key('delete_profile_image') ret = user.modify_user(user_id, locals()) if change_lang: web.ctx.session.lang = language raise web.seeother(util.link('/+u'))
def leave_post(self, current_uid = -1): user_id = current_uid usr = user.get_user(user_id)[1] password = web.input().password if not user.verify_password(user_id, password): return util.render().error(error_message= _('INVALID_PASSWORD'), help_context='error') result = user.delete_user(user_id) if not result[0]: return util.render().error(error_message = result[1], help_context='error') web.ctx.session.uid = 0 web.ctx.session.kill() raise web.seeother(util.link('/'))
def user_login(req): user_name = req.GET.get("user_name") password = req.GET.get("password") if not (user_name and password): return ApiResult(sc.E_PARAM) # 创建用户 user = user_ops.get_user(user_name) if not user: return ApiResult(sc.E_PARAM, msg='用户不存在') if not user_ops.verify_password(user_name, password): return ApiResult(sc.E_PARAM, msg='密码有误') # 登陆 if not req.user.is_authenticated: easy_login(req, user) req.session.set_expiry(7257600) return ApiResult(sc.E_SUCC, {"session_id": req.session.session_key})