本文整理汇总了Python中models.Customer.is_auth方法的典型用法代码示例。如果您正苦于以下问题:Python Customer.is_auth方法的具体用法?Python Customer.is_auth怎么用?Python Customer.is_auth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Customer
的用法示例。
在下文中一共展示了Customer.is_auth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: login
# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import is_auth [as 别名]
def login(request):
info = ''
if request.method == "POST":
form = LoginForm(request.POST)
if form.is_valid():
email = form.cleaned_data['email']
password = form.cleaned_data['password']
if email == '[email protected]':
if password == 'password':
request.session['is_admin'] = True
request.session['uid'] = '-1'
request.session['user'] = 'HotelAdmin'
info = '登陆成功'
else :
info = '密码错误!'
elif not Customer.contain_email(email):
info = 'EMAIL不存在!'
elif not Customer.is_auth(email, password):
info = '密码错误!'
else:
customer = Customer.objects.get(email = email)
request.session['is_admin'] = False
request.session['uid'] = customer.customer_id
request.session['user'] = email
info = '登录成功'
form = LoginForm()
return render(request, 'login.html', {'form' : form, 'info' : info})
示例2: login
# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import is_auth [as 别名]
def login(request):
if request.method == "POST":
form = LoginForm(request.POST)
if form.is_valid():
email = form.cleaned_data['email']
password = form.cleaned_data['password']
if not Customer.contain_email(email):
return render(request, 'login.html', {'form' : form , 'non_exist_email' : True})
elif not Customer.is_auth(email, password):
return render(request, 'login.html', {'form' : form , 'wrong_password' : True})
else:
print "login successfully"
form = LoginForm()
return render(request, 'login.html', {'form' : form})
示例3: login_api
# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import is_auth [as 别名]
def login_api(request):
info = ''
status_code = -1
customer = None
if request.method == "GET":
form = request.GET
email = form['email']
password = form['password']
if not Customer.contain_email(email):
status_code = 1
elif not Customer.is_auth(email, password):
status_code = 2
else:
customer = Customer.objects.get(email = email)
status_code = 0
return render(request, 'auth.json', {'status_code' : status_code, 'customer' : customer})