本文整理汇总了Python中CadVlan.Auth.AuthSession.AuthSession.login方法的典型用法代码示例。如果您正苦于以下问题:Python AuthSession.login方法的具体用法?Python AuthSession.login怎么用?Python AuthSession.login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CadVlan.Auth.AuthSession.AuthSession
的用法示例。
在下文中一共展示了AuthSession.login方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: login
# 需要导入模块: from CadVlan.Auth.AuthSession import AuthSession [as 别名]
# 或者: from CadVlan.Auth.AuthSession.AuthSession import login [as 别名]
def login(request):
modal_auto_open = "false"
if request.method == 'POST':
form = LoginForm(request.POST)
form_pass = PassForm()
if form.is_valid():
try:
client = ClientFactory(
NETWORK_API_URL, NETWORK_API_USERNAME, NETWORK_API_PASSWORD)
user = client.create_usuario().authenticate(form.cleaned_data[
'username'], form.cleaned_data['password'], form.cleaned_data['is_ldap_user'])
if user is None:
messages.add_message(
request, messages.ERROR, auth_messages.get("user_invalid"))
else:
request.session.set_expiry(SESSION_EXPIRY_AGE)
auth = AuthSession(request.session)
user = user.get('user')
if user.get('permission') is None:
messages.add_message(
request, messages.ERROR, auth_messages.get("nogroup_error"))
return render_to_response(templates.LOGIN, {'form': form, 'form_pass': form_pass, 'modal': modal_auto_open}, context_instance=RequestContext(request))
auth.login(User(user.get('id'), user.get('user'), user.get('nome'), user.get(
'email'), user.get('pwd'), user.get('permission'), user.get('ativo'), user.get('user_ldap')))
if form.cleaned_data['redirect'] != "":
return HttpResponseRedirect(form.cleaned_data['redirect'])
return HttpResponseRedirect(URL_HOME)
except InvalidParameterError, e:
logger.error(e)
messages.add_message(
request, messages.ERROR, auth_messages.get("user_invalid"))
except NetworkAPIClientError, e:
logger.error(e)
messages.add_message(request, messages.ERROR, e)
except LDAPNotFoundError, e:
logger.error(e)
messages.add_message(
request, messages.ERROR, auth_messages.get("user_ldap_not_found"))