def login(self):
if request.method != '<STR_LIT:POST>':<EOL><INDENT>cfg = NipapConfig()<EOL>try:<EOL><INDENT>c.welcome_message = cfg.get('<STR_LIT>', '<STR_LIT>')<EOL><DEDENT>except NoOptionError:<EOL><INDENT>pass<EOL><DEDENT>return render('<STR_LIT>')<EOL><DEDENT>try:<EOL><INDENT>auth_fact = AuthFactory()<EOL>auth = auth_fact.get_auth(request.params.get('<STR_LIT:username>'), request.params.get('<STR_LIT:password>'), '<STR_LIT>')<EOL>if not auth.authenticate():<EOL><INDENT>c.error = '<STR_LIT>'<EOL>return render('<STR_LIT>')<EOL><DEDENT><DEDENT>except AuthError as exc:<EOL><INDENT>c.error = '<STR_LIT>'<EOL>return render('<STR_LIT>')<EOL><DEDENT>session['<STR_LIT:user>'] = auth.username<EOL>session['<STR_LIT>'] = auth.full_name<EOL>session['<STR_LIT>'] = auth.readonly<EOL>session['<STR_LIT>'] = {}<EOL>session.save()<EOL>if session.get('<STR_LIT>'):<EOL><INDENT>redirect(session['<STR_LIT>'])<EOL><DEDENT>else:<EOL><INDENT>redirect(url(controller='<STR_LIT>', action='<STR_LIT:list>'))<EOL><DEDENT>
Show login form.