from user import User users = [User(1, 'joshue', 'abcd')] username_mapping = {u.username: u for u in users} userid_mapping = {u.id: u for u in users} def authenticate(username, password): user = username_mapping.get(username, None) if user and user.password == password: return user def identity(payload): user_id = payload['identity'] return userid_mapping.get(user_id, None)
from user import User from werkzeug.security import safe_str_cmp users = [User(1, 'Tiffany', 'qwerty')] # check for error here: username_table = {u.username: u for u in users} userid_table = {u.id: u for u in users} def authenticate(username, password): user = username_table.get(username, None) print("this should be firing", user) if user and safe_str_cmp(user.password, password): print("is there a user password?", user.password) return user def identity(payload): user_id = payload['identity'] return userid_table.get(user_id, None)
def menu(): name = input("Enter your name: ").strip() filename = "{}.txt".format(name) # check if file exist if file_exists(filename): with open(filename, 'r') as f: json_data = json.load( f) # loads contents of a file in the JSON format user = User.from_json_file(json_data) # if file doesn't exist create one else: user = User(name) print("\t\tWelcome, {}!".format( name.capitalize())) # display a welcome message menu_options() # display a list of options for the user to choose from user_input = int(input("Select from the menu: ") ) # capture the users input and typecast into an integer while user_input != 0: if user_input == 1: # add a movie movie_name = input("Enter movie name: ").strip() movie_genre = input("Enter movie genre: ").strip() user.add_movie(movie_name, movie_genre) elif user_input == 2: # view list of movies if user.emptylist( user.movies): # first check if the user has movies print("No movies yet, Enter (1) to add a movie!\n") else: for count, movie in enumerate(user.movies): print("{})".format(count + 1)) print("Name: {}\nGenre: {}\nWatched: {}\n".format( movie.name, movie.genre, movie.watched)) elif user_input == 3: # set movie as watched if user.emptylist( user.movies): # first check if the user has movies print("No movies in the list.") else: movie_name = input( "Enter the name of movie to set as watched: ").strip() user.set_watched(movie_name) elif user_input == 4: # delete a movie if user.emptylist( user.movies): # first check if the user has movies print("No movies in the list.") else: movie_name = input( "Enter the name of movie to set as watched: ").strip() user.delete_movie(movie_name) elif user_input == 5: # show watched movies if user.emptylist(user.watched_movies( )): # first check if the user has watched any movie print("No movies watched") else: for count, movie in enumerate(user.watched_movies()): print("{})".format(count + 1)) print("Name: {}\nGenre: {}\nWatched: {}\n".format( movie.name, movie.genre, movie.watched)) elif user_input == 6: # save user profile with open(filename, 'w') as f: json.dump(user.user_json(), f) print("File saved successfully as '{}'".format(filename)) menu_options() # display a list of options for the user to choose from user_input = int(input("Select from the menu: "))
from user import User users = [User(1, "nilo", "avocado")] username_mapping = {u.username: u for u in users} user_id_mapping = {u.id: u for u in users} def authenticate(username, password): user = username_mapping.get(username, None) if user and user.password == password: return user def identity(payload): user_id = payload["identity"] return user_id_mapping.get(user_id, None)
from playlist import Playlist from playlist_song import Playlist_song app = Flask(__name__) CORS(app) # Declaracion de objetos Users = [] Songs = [] Comments = [] Playlists = [] Playlist_song_array = [] # Datos ingresados Users.append(User(1, 'Angel', 'Ordon', 'root', 'root', 1)) Users.append(User(2, 'Diego', 'Pinto', 'diego', '123', 2)) Songs.append( Song( 1, 'International Love', 'Fidel Nadal', 'International Love', 'https://images-na.ssl-images-amazon.com/images/I/61AobF8AZLL._SY355_.jpg', '2008', 'https://open.spotify.com/embed/track/2O282x8rik9PMihQAx6bAq', 'https://www.youtube.com/embed/y3WGp_ZEGUo', 1)) Songs.append( Song(2, 'Vibra Positiva', 'Zona Ganjah', 'Con Rastafari Todo Concuerda', 'https://i.scdn.co/image/ab67616d0000b273fb61203117d2324964d71c47', '2005', 'https://open.spotify.com/embed/track/061cp08tzW2q8qaqNkad28', 'https://www.youtube.com/embed/lFw6sxMGIHk', 1)) Songs.append(
from user import User users = { 1: User('test', 'test', 1) }
from question_model import Question from data import question_data from quiz_brain import QuizBrain, final_score from user import User q_bank = [] user_name = input('Hi! Pls input your first name:') for question in question_data: question_text = question['text'] question_answer = question['answer'] new_question = Question(question_text, question_data) q_bank.append(new_question) quiz = QuizBrain(q_bank) final_score = quiz.next_question() globals()[user_name] = User(user_name, final_score) globals()[user_name].record_me()
def setUp(self): ''' set up method runs before evry testcase ''' self.new_user = User("manu", "lilfranken", "*****@*****.**")