Skip to content

History

Revisions

  • from flask import Flask, request, jsonify import re from datetime import datetime import logging app = Flask(__name__) # Configure logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) class PasswordValidator: @staticmethod def is_strong_password(password: str) -> tuple[bool, str]: """ Validates password strength based on the following rules: - Minimum 12 characters - At least one uppercase letter - At least one lowercase letter - At least one number - At least one special character - No common patterns """ if len(password) < 12: return False, "Password must be at least 12 characters long" if not re.search(r'[A-Z]', password): return False, "Password must contain at least one uppercase letter" if not re.search(r'[a-z]', password): return False, "Password must contain at least one lowercase letter" if not re.search(r'\d', password): return False, "Password must contain at least one number" if not re.search(r'[!@#$%^&*(),.?":{}|<>]', password): return False, "Password must contain at least one special character" # Check for common patterns common_patterns = [ r'12345', r'qwerty', r'password', r'admin', r'abc123' ] for pattern in common_patterns: if re.search(pattern, password.lower()): return False, f"Password contains a common pattern: {pattern}" return True, "Password meets all requirements" @app.route('/api/signup', methods=['POST']) def signup(): try: data = request.get_json() if not data: return jsonify({ 'success': False, 'message': 'No data provided' }), 400 # Extract required fields email = data.get('email') password = data.get('password') username = data.get('username') # Validate required fields if not all([email, password, username]): return jsonify({ 'success': False, 'message': 'Missing required fields: email, password, and username are required' }), 400 # Validate email format email_pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$' if not re.match(email_pattern, email): return jsonify({ 'success': False, 'message': 'Invalid email format' }), 400 # Validate password strength is_strong, message = PasswordValidator.is_strong_password(password) if not is_strong: return jsonify({ 'success': False, 'message': f'Password is not strong enough: {message}' }), 400 # TODO: Add your database logic here to save the user # Make sure to hash the password before storing it! # Log successful signup attempt (excluding sensitive data) logger.info(f"Successful signup attempt for user: {username} at {datetime.utcnow()}") return jsonify({ 'success': True, 'message': 'User registered successfully', 'data': { 'username': username, 'email': email } }), 201 except Exception as e: logger.error(f"Error during signup: {str(e)}") return jsonify({ 'success': False, 'message': 'An error occurred during signup' }), 500 if __name__ == '__main__': app.run(debug=False)

    @joonih joonih committed Feb 7, 2025
    5c1f623
  • Updated ReSpec Editor's Guide (markdown)

    @TimvdLippe TimvdLippe committed Jan 16, 2025
    62ef602
  • Updated ReSpec Editor's Guide (markdown)

    @TimvdLippe TimvdLippe committed Jan 16, 2025
    a1e75fe
  • i installled webpack and react and then fetced some addons dunno even what they are

    @cbacc00 cbacc00 committed Jan 15, 2025
    da8778a
  • Updated ReSpec Editor's Guide (markdown)

    @Pawaris2732 Pawaris2732 committed Dec 18, 2024
    94894ad
  • add note about not opening file://

    @sidvishnoi sidvishnoi committed Nov 27, 2024
    003059e
  • Created Hhsd (markdown)

    @Access1919 Access1919 committed Nov 22, 2024
    3ee42ea
  • Updated ReSpec Editor's Guide (markdown)

    @tiakuzo tiakuzo committed Nov 9, 2024
    c7a5ed2
  • Updated ednote (markdown)

    @Quangbavet Quangbavet committed Sep 21, 2024
    bace007
  • Updated isPreview (markdown)

    @7IAM7 7IAM7 committed Sep 5, 2024
    d2cbdb1
  • Honor repo transfer

    @daniel-montalvo daniel-montalvo committed Aug 21, 2024
    f7bada6
  • Updated Developers Guide (markdown)

    @anhtai9710 anhtai9710 committed Aug 9, 2024
    e474824
  • The config option is singular not plural

    @jnurthen jnurthen committed Jul 29, 2024
    d41a70f
  • Updated Developers Guide (markdown)

    @ralfhandl ralfhandl committed Jul 9, 2024
    edeb452
  • Update link to linter rules

    @ralfhandl ralfhandl committed Jul 4, 2024
    02f9cbd
  • Adding Discontinued Draft

    @deniak deniak committed Jun 25, 2024
    ecba4a4
  • Undo vandalism of following commits: commit 5897490bcb62935676cfb94dee150274c011222a Author: GITHUBGooOdD <1004cjstkz@gmail.com> Date: Thu May 30 14:14:06 2024 +0900 commit 264309b9e1c37934dd53bbac199f7032c7a373f6 Author: Saufifii <furqanlizar34@gmail.com> Date: Sun May 26 06:16:26 2024 +0700

    @sidvishnoi sidvishnoi committed Jun 3, 2024
    29c007a
  • Updated informative dfn (markdown)

    @sidvishnoi sidvishnoi committed May 24, 2024
    0a45f9c
  • Updated lint ignore (markdown)

    @sidvishnoi sidvishnoi committed May 24, 2024
    b9504f9
  • Updated lint ignore (markdown)

    @sidvishnoi sidvishnoi committed May 24, 2024
    b71ae44
  • Updated informative dfn (markdown)

    @sidvishnoi sidvishnoi committed May 24, 2024
    c7ea326
  • Updated no unused dfns (markdown)

    @sidvishnoi sidvishnoi committed May 24, 2024
    c128944
  • Created lint ignore (markdown)

    @caribouW3 caribouW3 committed May 24, 2024
    b13ebd5
  • Updated informative dfn (markdown)

    @caribouW3 caribouW3 committed May 24, 2024
    b85d641
  • doc for informative-dfn

    @caribouW3 caribouW3 committed May 24, 2024
    6a75579
  • link to informative dfn doc

    @caribouW3 caribouW3 committed May 24, 2024
    198c1a6
  • doc for no-unused-dfns

    @caribouW3 caribouW3 committed May 24, 2024
    2f36994
  • Destroyed no‐unused‐dfns (markdown)

    @caribouW3 caribouW3 committed May 24, 2024
    c5a1df6
  • Updated no‐unused‐dfns (markdown)

    @caribouW3 caribouW3 committed May 24, 2024
    be28656
  • link to no-unused-dfns doc

    @caribouW3 caribouW3 committed May 24, 2024
    8c93ddc