示例#1
0
async def reset_password(request):
    if request.method == 'GET':
        token = request.args.get("token", None)
        static_url = app.config.get("DOMAIN_URL")+"/"+app.config.get("STATIC_URL", "")
        return jinja.render('email/reset_password.html', request, static_url = static_url, token=token)
    
     
    if request.method == 'POST':
        token = request.form.get("token", None)
        password = request.form.get("password", None)
        confirm_password = request.form.get("confirm_password", None)
         
         
        if token is None or password  is None:
            return json({"error_code": "PARAM_ERROR", "error_message": "Tham số không hợp lệ, vui lòng thực hiện lại"}, status=520)

        uid_current = redisdb.get("sessions:" + token)
        if uid_current is None:
            return json({"error_code": "SESSION_EXPIRED", "error_message": "Hết thời gian thay đổi mật khẩu, vui lòng thực hiện lại"}, status=520)
    
         
        
        redisdb.delete("sessions:" + token)         
        user = User.query.filter(User.id == str(uid_current.decode('ascii'))).first()
        if (user is not None):
            user.password = auth.encrypt_password(password)
            auth.login_user(request, user)
            db.session.commit()
            return text(u'bạn đã lấy lại mật khẩu thành công. mời bạn đăng nhập lại để sử dụng!')
        else:
            return text('Không tìm thấy tài khoản trong hệ thống, vui lòng thử lại sau!')
示例#2
0
async def reset_password(request):
    if request.method == 'GET':
        token = request.args.get("token", None)
        static_url = app.config.get("DOMAIN_URL")+"/"+app.config.get("STATIC_URL", "")
        return jinja.render('email/reset_password.html', request, static_url = static_url, token=token)
    
     
    if request.method == 'POST':
        token = request.form.get("token", None)
        password = request.form.get("password", None)
        confirm_password = request.form.get("confirm_password", None)
         
         
        if token is None or password  is None:
            return json({"error_code": "PARAM_ERROR", "error_message": "Invalid value, please check again"}, status=520)

        uid_current = redisdb.get("sessions:" + token)
        if uid_current is None:
            return json({"error_code": "SESSION_EXPIRED", "error_message": "Timeout to change password, please select again"}, status=520)
    
         
        
        redisdb.delete("sessions:" + token)         
        user = User.query.filter(User.id == str(uid_current.decode('ascii'))).first()
        if (user is not None):
            user.password = auth.encrypt_password(password)
            auth.login_user(request, user)
            db.session.commit()
            return text(u'Password change was successful.')
        else:
            return text('User account not found, please select again!')
示例#3
0
async def resetpw_email(request):
    if request.method == 'GET':
        token = request.args.get("token", None)
        static_url = app.config.get("DOMAIN_URL")+"/"+app.config.get("STATIC_URL", "")
        return jinja.render('email/reset_password.html', request, static_url = static_url, token=token)
    
    if request.method == 'POST':
        email = request.json.get("email", None)
        if ((email is None) or (email == '')):
            return json({"error_code": "PARRAM_ERROR", "error_message": "tham số không hợp lệ"},status=520) 
            
        checkuser = db.session.query(User).filter(User.email == email).first()
        if(checkuser is not None):
            await send_reset_password_instructions(request, checkuser)
            return json({"error": 0, "error_message": u"Yêu cầu thành công, mời bạn kiểm tra lại email để thiết lập lại mật khẩu!"})
        else:
            return json({"error_code": "PARRAM_ERROR", "error_message": "Email không tồn tại trong hệ thống"},status=520) 
    return json({"error": "ERROR_RESET", "error_message": 'Không có quyền truy cập'}, status=520)
示例#4
0
async def resetpw_email(request):
    if request.method == 'GET':
        token = request.args.get("token", None)
        static_url = app.config.get("DOMAIN_URL")+"/"+app.config.get("STATIC_URL", "")
        return jinja.render('email/reset_password.html', request, static_url = static_url, token=token)
    
    if request.method == 'POST':
        email = request.json.get("email", None)
        if ((email is None) or (email == '')):
            return json({"error_code": "PARRAM_ERROR", "error_message": "Invalid value, please check again"},status=520) 
            
        checkuser = db.session.query(User).filter(User.email == email).first()
        if(checkuser is not None):
            await send_reset_password_instructions(request, checkuser)
            return json({"error": 0, "error_message": u"Success!!, Request has been sent via gmail"})
        else:
            return json({"error_code": "PARRAM_ERROR", "error_message": "Email is already used in another account"},status=520) 
    return json({"error": "ERROR_RESET", "error_message": 'There is no right to perform this action'}, status=520)
async def medicalform_form(request, lang, cuakhau_id):

    print('lang--------------------------------------------------', lang)
    if lang in ["vi", "cn", "en"]:
        # data = {
        #     "cuakhau_id": cuakhau_id
        # }
        # cuakhau = CuaKhau.query.filter(CuaKhau.id == cuakhau_id).first()
        data = get_cuakhau_info(cuakhau_id)
        data["ngon_ngu"] = lang
        # print(cuakhau)
        # data = {
        #     "cuakhau_id": cuakhau_id,
        #     "tencuakhau":cuakhau.ten,
        #     "donvi_id": cuakhau.donvi_id,
        #     "ngon_ngu": lang
        # }
        return jinja.render('medicalform/form_' + lang + '.html', request,
                            **data)
示例#6
0
文件: __init__.py 项目: ntakma/gatco
 def index(request):
     #return text("Index")
     return jinja.render('index.html', request)
示例#7
0
 def index(request):
     return jinja.render('layout.html', request)
async def medicalform_form_history(request, lang, cuakhau_id):
    return jinja.render('medicalform/form_' + lang + '.html', request)
async def medicalform_index_history(request, cuakhau_id):
    return jinja.render('medicalform/index.html', request)
async def medicalform_index(request, cuakhau_id):
    data = get_cuakhau_info(cuakhau_id)
    return jinja.render('medicalform/index.html', request, **data)
示例#11
0
 def index(request):
     return jinja.render('index.html', request)
示例#12
0
 def index(request):
     return jinja.render('huongdansudung/huongdansudung.html', request)
示例#13
0
async def contact(request):
    #     return jinja.render('admin/index.html', request)
    return jinja.render('dieukhoan.html', request)
示例#14
0
async def index(request):
    return jinja.render('landingpage.html', request)