Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Sign up and login workflows
📖 Scenario: You are creating a simple sign up and login system for a small website. This system will help users create accounts and then log in using their credentials.
🎯 Goal: Build a clear step-by-step workflow that shows how users sign up with a username and password, and then log in using those details.
📋 What You'll Learn
Create a data structure to store user accounts with usernames and passwords
Add a variable to track the current logged-in user
Write the main logic to check user credentials during login
Complete the workflow by adding a confirmation step for successful login
💡 Why This Matters
🌍 Real World
Sign up and login workflows are essential for websites and apps to manage user access securely and personalize experiences.
💼 Career
Understanding these workflows is important for roles in web development, user experience design, and security.
Progress0 / 4 steps
1
Create user accounts data structure
Create a dictionary called user_accounts with these exact entries: 'alice': 'pass123', 'bob': 'qwerty', and 'carol': 'abc123' to store usernames and passwords.
No-Code
Hint
Use a dictionary with usernames as keys and passwords as values.
2
Add current user tracking variable
Create a variable called current_user and set it to None to track who is logged in.
No-Code
Hint
Use None to show no user is logged in yet.
3
Check login credentials
Write an if statement that checks if the username input_username exists in user_accounts and if the password input_password matches the stored password. If both are true, set current_user to input_username.
No-Code
Hint
Use if with in to check username and compare passwords.
4
Confirm successful login
Add a final if statement that checks if current_user is not None. If true, set a variable login_status to 'Login successful'.
No-Code
Hint
Check if current_user is set and then assign login_status.
Practice
(1/5)
1. What is the main purpose of a sign up process in an app or website?
easy
A. To create a new user account
B. To reset a forgotten password
C. To log out from the account
D. To update user profile information
Solution
Step 1: Understand the sign up process
Sign up is the step where a new user provides details to create an account.
Step 2: Differentiate from other actions
Resetting password, logging out, or updating profile happen after account creation.
Final Answer:
To create a new user account -> Option A
Quick Check:
Sign up = create account [OK]
Hint: Sign up means making a new account [OK]
Common Mistakes:
Confusing sign up with login
Thinking sign up resets password
Mixing sign up with logout
2. Which of the following is the correct order in a typical login workflow?
easy
A. Enter password, enter username, access account, verify credentials
B. Verify credentials, enter password, enter username, access account
C. Access account, enter username, enter password, verify credentials
D. Enter username, enter password, verify credentials, access account
Solution
Step 1: Identify login steps
Login starts by entering username, then password, then system checks credentials.
Step 2: Confirm correct sequence
Only Enter username, enter password, verify credentials, access account follows the logical order: username, password, verify, then access.
Final Answer:
Enter username, enter password, verify credentials, access account -> Option D
Hint: Login always starts with username then password [OK]
Common Mistakes:
Swapping username and password order
Verifying before entering credentials
Accessing account before verification
3. Consider this login workflow: User enters email and password, system checks if email exists, then verifies password. What happens if the email is not found?
medium
A. System asks for password again
B. User is logged in anyway
C. User receives an error message about invalid email
D. User account is created automatically
Solution
Step 1: Analyze email check in login
If the email is not found, the system cannot verify password or log in the user.
Step 2: Determine system response
The system should inform the user that the email is invalid or not registered.
Final Answer:
User receives an error message about invalid email -> Option C
Quick Check:
Email not found = error message [OK]
Hint: No email found means login error message [OK]
Common Mistakes:
Assuming login succeeds without email
Thinking system retries password input
Believing account auto-creates on login
4. A login form requires username and password. The system always accepts any username but rejects all passwords. What is the likely error?
medium
A. User session is not created
B. Password verification logic is incorrect
C. Login form does not submit data
D. Username input is missing
Solution
Step 1: Identify the problem in password handling
Since all passwords are rejected, the password check logic likely has a bug.
Step 2: Rule out other causes
Username is accepted, form submits data, and session creation happens after login success, so these are less likely.
Final Answer:
Password verification logic is incorrect -> Option B
Quick Check:
All passwords rejected = password check bug [OK]
Hint: If all passwords fail, check password verification code [OK]
Common Mistakes:
Blaming username input when it works
Assuming form doesn't submit without checking
Confusing session creation with login validation
5. You want to improve security in a sign up and login workflow by adding a step that prevents automated bots from creating accounts. Which method is best to add?
hard
A. Add a CAPTCHA challenge during sign up
B. Require users to enter their phone number only
C. Allow login without password for convenience
D. Skip email verification to speed up sign up
Solution
Step 1: Understand bot prevention methods
CAPTCHA challenges are designed to block automated bots by requiring human interaction.