tickets

tickets.worldapi.org #46

The login logic exists twice and is not thin: lib/api.hl loginCallback and components/main.hl identLogin

done

opened by Atlas

opened · updated

Audit (layouts.worldapi.org#6), checklist item: 16.5 API, faces and page handlers are thin wrappers.

The ident login is implemented twice. components/main.hl lines 193-206 (face identLogin): exchange the code, ensure the user, draw a random tag, write session.user and session.data.tag, build the info, emit signedIn. lib/api.hl lines 485-512 (loginCallback, about 28 lines): exchange the code, ensure the user, optionally join an invite, mint a session if none, write session.user and session.data.tag, save, build the redirect, set the cookie. Both contain the real login steps, so a change such as the one in ident#28 has to be made twice. Smaller cases over the 10-line mark: components/ticket_list.hl on create (17 lines), components/project-form.hl on create (13), components/connect.hl on confirm (12), components/settings.hl settingsInvite (12).

The framework way: one function in lib/users.hl (login with an ident code, optional invite) that does the steps once; the face and the route are thin wrappers that call it and return. The component handlers hand the input to a lib function and write the answer to members.

History

  1. Atlas opened the ticket
  2. Atlas edited the ticket
    Summary before

    Audit (layouts.worldapi.org#6), checklist item: 16.5 API, faces and page handlers are thin wrappers.

    The ident login is implemented twice. components/main.hl lines 205-215 (face identLogin): exchange the code, ensure the user, draw a random tag, write session.user and session.data.tag, build the info, emit signedIn. lib/api.hl lines 485-512 (loginCallback, about 28 lines): exchange the code, ensure the user, optionally join an invite, mint a session if none, write session.user and session.data.tag, save, build the redirect, set the cookie. Both contain the real login steps, so a change such as the one in ident#28 has to be made twice. Smaller cases over the 10-line mark: components/ticket_list.hl on create (17 lines), components/project-form.hl on create (13), components/connect.hl on confirm (12), components/settings.hl settingsInvite (12).

    The framework way: one function in lib/users.hl (login with an ident code, optional invite) that does the steps once; the face and the route are thin wrappers that call it and return. The component handlers hand the input to a lib function and write the answer to members.

  3. 1 comment

    1. Tickets
        Write…
    2. Tickets changed the state done

    Reading is open to everyone. To comment or change the state, log in with ident (top right) and choose a display name.