<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def login(self):
 """ Show login form. """


        if request.method != 'POST':
            cfg = NipapConfig()
            try:
                c.welcome_message = cfg.get('www', 'welcome_message')
            except NoOptionError:
                pass

            return render('login.html')

        # Verify username and password.
        try:
            auth_fact = AuthFactory()
            auth = auth_fact.get_auth(request.params.get('username'), request.params.get('password'), 'nipap')
            if not auth.authenticate():
                c.error = 'Invalid username or password'
                return render('login.html')
        except AuthError as exc:
            c.error = 'Authentication error'
            return render('login.html')

        # Mark user as logged in
        session['user'] = auth.username
        session['full_name'] = auth.full_name
        session['readonly'] = auth.readonly
        session['current_vrfs'] = {}
        session.save()

        # Send user back to the page he originally wanted to get to
        if session.get('path_before_login'):
            redirect(session['path_before_login'])

        else:
            # if previous target is unknown just send the user to a welcome page
            redirect(url(controller='prefix', action='list'))