def register(req): logo_image = fun.get_site_logo(req) cate_name = '用户注册' if req.method == 'GET': data = {} express, express_id = controller.get_valid_code() fun.get_valid_code() return render_to_response("zhiyuw/register.html", locals(), context_instance=RequestContext(req)) elif req.method == 'POST': data = fun.warp_data(req.POST) if data['password'] != data['password2']: msg = '两次密码不一致' else: if req.META.has_key('HTTP_X_FORWARDED_FOR'): data['ip'] = req.META['HTTP_X_FORWARDED_FOR'] else: data['ip'] = req.META['REMOTE_ADDR'] r = controller.reg_user(req, data) # print r if r > 0: info = controller.auth(req, data) req.session['isLogin'] = True req.session['info'] = info return render_to_response("zhiyuw/reg_yd.html", locals(), context_instance=RequestContext(req)) else: msg = '该用户名或邮箱已注册,' express, express_id = controller.get_valid_code() fun.get_valid_code() return render_to_response("zhiyuw/register.html", locals(), context_instance=RequestContext(req))
def do_admin_login(): user = request.form['username'] password = request.form['password'] if controller.auth(user, password): session['logged_in'] = True else: flash('wrong password!') return redirect('/')
def login(req): settings = setting if req.method=='GET': return render_to_response("backend/login.html", locals()) elif req.method=='POST': data = req.POST if controller.auth(req, data): return HttpResponseRedirect('/backend/') else: msg = '用户名或密码错误' return render_to_response("backend/msg.html", locals())
def login(req): settings = setting if req.method == 'GET': return render_to_response("backend/login.html", locals()) elif req.method == 'POST': data = req.POST if controller.auth(req, data): return HttpResponseRedirect('/backend/') else: msg = '用户名或密码错误' return render_to_response("backend/msg.html", locals())
def user_auth(): json = request.get_json(force=True) login = json['login'] password = json['password'] result = {'data': '', 'error': ''} code = 200 try: token = controller.auth( login, password) # пытаемся пройти аутентификацию и получить JWT токен result['data'] = str(token) except Exception as e: result['error'] = repr(e) print(result) # выводим лог в stdout code = 400 return jsonify(result), code
def login(req): logo_image = fun.get_site_logo(req) cate_name = '用户登录' if req.method=='GET': return render_to_response("zhiyuw/login.html", locals(), context_instance = RequestContext(req)) elif req.method=='POST': data = fun.warp_data(req.POST) r = controller.auth(req, data) if r: # print r req.session['isLogin'] = True req.session['info'] = r return HttpResponseRedirect("/members") else: msg = '用户或密码错误' return render_to_response("zhiyuw/msg.html", locals(), context_instance = RequestContext(req))
def login(req): logo_image = fun.get_site_logo(req) cate_name = '用户登录' if req.method == 'GET': third_appid = qq_appid return render_to_response("zhiyuw/login.html", locals(), context_instance=RequestContext(req)) elif req.method == 'POST': data = fun.warp_data(req.POST) r = controller.auth(req, data) if r: # print r req.session['3rd_not_init'] = False req.session['isLogin'] = True req.session['info'] = r return HttpResponseRedirect("/members") else: msg = '用户或密码错误' return render_to_response("zhiyuw/msg.html", locals(), context_instance=RequestContext(req))