Versions

  • v11

    8/25/2024
    Open: Version
    Changes from v10 to v11
    +11
    -2
    ⦚ 32 unchanged lines ⦚
    `);

    const existingUser = await sqlite.execute({
    sql: `SELECT * FROM ${TABLE_NAME} WHERE username = ?`,
    args: [username],
    });

    const bannedCharacters = [
    ⦚ 54 unchanged lines ⦚
    }

    // User exists, verify password
    const user = existingUser.rows[0];
    const storedPassword = user[2];
    ⦚ 13 unchanged lines ⦚
    ⦚ 32 unchanged lines ⦚
    `);

    // Check for existing user
    let existingUser = await sqlite.execute({
    sql: `SELECT * FROM ${TABLE_NAME} WHERE username = ?`,
    args: [username],
    });

    // User not found with that username. Check if any banned users used to have that username.
    if (existingUser.rows.length === 0) {
    existingUser = await sqlite.execute({
    sql: `SELECT * FROM ${TABLE_NAME} WHERE pre_ban_username = ?`,
    args: [username],
    });
    }

    const bannedCharacters = [
    ⦚ 54 unchanged lines ⦚
    }

    // User exists, verify password and check if banned
    const user = existingUser.rows[0];
    const storedPassword = user[2];
    ⦚ 13 unchanged lines ⦚
  • v10

    8/25/2024
    Open: Version
    Changes from v9 to v10
    +5
    -0
    ⦚ 98 unchanged lines ⦚
    const storedPassword = user[2];
    const passwordMatch = await bcrypt.compare(password, storedPassword);

    if (passwordMatch) {
    ⦚ 5 unchanged lines ⦚
    ⦚ 98 unchanged lines ⦚
    const storedPassword = user[2];
    const passwordMatch = await bcrypt.compare(password, storedPassword);
    const isBanned = user[5];

    if (isBanned) {
    return new Response(JSON.stringify({ error: "user is banned" }), { status: 401 });
    }

    if (passwordMatch) {
    ⦚ 5 unchanged lines ⦚
  • v9

    8/24/2024
    Open: Version
    Changes from v8 to v9
    +1
    -1
    ⦚ 27 unchanged lines ⦚
    password TEXT NOT NULL,
    status TEXT DEFAULT 'hello i am new',
    last_updated DATETIME DEFAULT CURRENT_TIMESTAMP
    is_banned INTEGER DEFAULT 0
    )
    ⦚ 75 unchanged lines ⦚
    ⦚ 27 unchanged lines ⦚
    password TEXT NOT NULL,
    status TEXT DEFAULT 'hello i am new',
    last_updated DATETIME DEFAULT CURRENT_TIMESTAMP,
    is_banned INTEGER DEFAULT 0
    )
    ⦚ 75 unchanged lines ⦚
  • v8

    8/24/2024
    Open: Version
    Changes from v7 to v8
    +1
    -1
    ⦚ 28 unchanged lines ⦚
    status TEXT DEFAULT 'hello i am new',
    last_updated DATETIME DEFAULT CURRENT_TIMESTAMP
    is_banned BOOLEAN DEFAULT 0
    )
    `);
    ⦚ 74 unchanged lines ⦚
    ⦚ 28 unchanged lines ⦚
    status TEXT DEFAULT 'hello i am new',
    last_updated DATETIME DEFAULT CURRENT_TIMESTAMP
    is_banned INTEGER DEFAULT 0
    )
    `);
    ⦚ 74 unchanged lines ⦚
  • v7

    8/24/2024
    Open: Version
    Changes from v6 to v7
    +2
    -2
    ⦚ 18 unchanged lines ⦚
    }

    const TABLE_NAME = "lab_login_users_with_times";

    // Create users table if it doesn't exist
    ⦚ 5 unchanged lines ⦚
    status TEXT DEFAULT 'hello i am new',
    last_updated DATETIME DEFAULT CURRENT_TIMESTAMP
    isbanned BOOLEAN DEFAULT FALSE
    )
    `);
    ⦚ 74 unchanged lines ⦚
    ⦚ 18 unchanged lines ⦚
    }

    const TABLE_NAME = "loginredux_users";

    // Create users table if it doesn't exist
    ⦚ 5 unchanged lines ⦚
    status TEXT DEFAULT 'hello i am new',
    last_updated DATETIME DEFAULT CURRENT_TIMESTAMP
    is_banned BOOLEAN DEFAULT 0
    )
    `);
    ⦚ 74 unchanged lines ⦚
  • v6

    8/24/2024
    Open: Version
    Changes from v5 to v6
    +1
    -1
    ⦚ 18 unchanged lines ⦚
    }

    const TABLE_NAME = "labloginredux_users";

    // Create users table if it doesn't exist
    ⦚ 84 unchanged lines ⦚
    ⦚ 18 unchanged lines ⦚
    }

    const TABLE_NAME = "lab_login_users_with_times";

    // Create users table if it doesn't exist
    ⦚ 84 unchanged lines ⦚
  • v5

    8/24/2024
    Open: Version
    Changes from v4 to v5
    +1
    -1
    ⦚ 18 unchanged lines ⦚
    }

    const TABLE_NAME = "lab_login_users_with_times";

    // Create users table if it doesn't exist
    ⦚ 84 unchanged lines ⦚
    ⦚ 18 unchanged lines ⦚
    }

    const TABLE_NAME = "labloginredux_users";

    // Create users table if it doesn't exist
    ⦚ 84 unchanged lines ⦚
  • v4

    8/24/2024
    Open: Version
    Changes from v3 to v4
    +1
    -1
    ⦚ 18 unchanged lines ⦚
    }

    const TABLE_NAME = "loginredux_users";

    // Create users table if it doesn't exist
    ⦚ 84 unchanged lines ⦚
    ⦚ 18 unchanged lines ⦚
    }

    const TABLE_NAME = "lab_login_users_with_times";

    // Create users table if it doesn't exist
    ⦚ 84 unchanged lines ⦚
  • v3

    8/24/2024
    Open: Version
    +107
    -0

    import * as bcrypt from "https://deno.land/x/bcrypt@v0.4.1/mod.ts";
    import { email } from "https://esm.town/v/std/email";
    import { sqlite } from "https://esm.town/v/std/sqlite";

    export default async function(req: Request): Promise<Response> {
    const body = await req.json();
    let { username, password } = body;

    if (!username || !password) {
    return new Response(JSON.stringify({ error: "Missing username or password" }), { status: 400 });
    }

    if (password.length > 50) {
    return new Response(JSON.stringify({ error: "Password too long" }), { status: 400 });
    }

    if (username.length > 50) {
    return new Response(JSON.stringify({ error: "Username too long" }), { status: 400 });
    }

    const TABLE_NAME = "loginredux_users";

    // Create users table if it doesn't exist
    await sqlite.execute(`
    CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    username TEXT UNIQUE NOT NULL,
    password TEXT NOT NULL,
    status TEXT DEFAULT 'hello i am new',
    last_updated DATETIME DEFAULT CURRENT_TIMESTAMP
    isbanned BOOLEAN DEFAULT FALSE
    )
    `);

    const existingUser = await sqlite.execute({
    sql: `SELECT * FROM ${TABLE_NAME} WHERE username = ?`,
mittzy-loginredux_login.web.val.run
Updated: November 16, 2024