from django.contrib.auth import authenticate, login

from BaseLib.BaseView import BaseView


class WelcomeView(BaseView):
    required_login = False
    endpoint = 'welcome'
    view_file = 'welcome.html'

    def post(self):
        username = self.request.POST['username']
        password = self.request.POST['password']
        user = authenticate(username=username, password=password)
        if user is None:
            return self
        login(self.request, user)
        return '/'
