示例#1
0
文件: views.py 项目: none-da/zeshare
def view_login(request, login_template, next=''):
    from users.forms import LoginForm
    if request.method == 'POST':
        form = LoginForm(post_data(request))
        if form.is_valid():
            userprofile = UserProfile.objects.get(email=form.cleaned_data.get('email'))
            if not userprofile.user.check_password(form.cleaned_data.get('password')):
                from users.messages import USER_LOGIN_FAILURE
                django_messages_framework.error(request, USER_LOGIN_FAILURE)
                return response(request, login_template, {'form': form, 'next': next})
            from users.messages import USER_LOGIN_SUCCESSFUL
            django_messages_framework.success(request, USER_LOGIN_SUCCESSFUL)
            return _let_user_login(request,
                                   userprofile.user,
                                   email=form.cleaned_data.get('email'),
                                   password=form.cleaned_data.get('password'),
                                   next=form.cleaned_data.get('next'))
    else:
        form = LoginForm()
    return response(request, login_template, {'form': form, 'next': next})
示例#2
0
 def message_error(self, message):
     error(self.request, message)
示例#3
0
 def message_error(self, message):
     error(self.request, message)