33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
from flask import Flask, request, session
|
|
from lernplattform import app
|
|
from lernplattform.models import User
|
|
|
|
class login():
|
|
"""
|
|
A class for handling user login functionality.
|
|
|
|
Attributes:
|
|
user_name (str): The username to be checked for authentication.
|
|
|
|
Methods:
|
|
__init__(self, user_name=None): Initializes the login object with a given user name.
|
|
check(user_name): A static method that checks if the provided user name is valid.
|
|
login(self): Prints "Login" to indicate that the login method has been called.
|
|
"""
|
|
def __init__(self, user_name=None):
|
|
self.user_name = user_name # Initialize the user name attribute for the login class
|
|
|
|
def check(user_name):
|
|
if user_name is None:
|
|
session['logged_in'] = False
|
|
session['user_name'] = 'Gast'
|
|
return False # Return False if the user name is not provided
|
|
else:
|
|
session['logged_in'] = True
|
|
session['user_name'] = user_name
|
|
|
|
return True # Otherwise, return True indicating a valid user name
|
|
|
|
def login(self):
|
|
print("Login") # Print "Login" to indicate that the login method has been called
|