providing password reset services for a long while: circa 2025

feat: add basic signup process

Changed files
+88 -4
features
+1 -1
bun.lock
··· 4 4 "": { 5 5 "name": "kreva", 6 6 "dependencies": { 7 - "slack-edge": "^1.3.2", 7 + "slack-edge": "^1.3.7", 8 8 }, 9 9 "devDependencies": { 10 10 "@types/bun": "latest",
+86 -2
features/signup.ts
··· 20 20 block_id: "password", 21 21 element: { 22 22 type: "plain_text_input", 23 - action_id: "set-password", 23 + action_id: "set_password", 24 24 focus_on_load: true, 25 25 min_length: 6, 26 26 placeholder: { ··· 53 53 }, 54 54 value: "next", 55 55 style: "primary", 56 - action_id: "set-password", 56 + action_id: "set_password", 57 57 }, 58 58 { 59 59 type: "button", ··· 67 67 ], 68 68 }, 69 69 ], 70 + }); 71 + }); 72 + 73 + slackApp.action("set_password", async ({ context, payload }) => { 74 + if (!context?.respond) return; 75 + 76 + // @ts-expect-error 77 + const password: null | string = 78 + payload?.state.values.password.set_password.value; 79 + const user = ( 80 + await context.client.users.info({ user: context.userId as string }) 81 + ).user?.profile || { email: "unknown" }; 82 + 83 + if ( 84 + payload?.type !== "block_actions" || 85 + (payload?.actions[0].block_id === "password" && !password) 86 + ) { 87 + await context.respond({ 88 + response_type: "ephemeral", 89 + text: "boooooo. `null` passwords are not allowed :(\n\nmake it at least 6 characters and try again!", 90 + }); 91 + return; 92 + } 93 + 94 + await context.respond({ 95 + response_type: "ephemeral", 96 + text: "does this look good to you? :eyes:", 97 + blocks: [ 98 + { 99 + type: "section", 100 + text: { 101 + type: "mrkdwn", 102 + text: "does this look good to you? :eyes:", 103 + }, 104 + }, 105 + { type: "divider" }, 106 + { 107 + type: "section", 108 + text: { 109 + type: "mrkdwn", 110 + text: `*hackatime profile*\n\norpheus mail: \`${user.email}\`\npassphrase: \`${password}\`\nusername: \`${context.userId}\``, 111 + }, 112 + }, 113 + { 114 + type: "actions", 115 + elements: [ 116 + { 117 + type: "button", 118 + text: { 119 + type: "plain_text", 120 + text: "yes, looks good!", 121 + }, 122 + value: "yes", 123 + style: "primary", 124 + action_id: "make-account", 125 + }, 126 + { 127 + type: "button", 128 + text: { 129 + type: "plain_text", 130 + text: "no, let me change it", 131 + }, 132 + value: "no", 133 + action_id: "bad-info", 134 + }, 135 + ], 136 + }, 137 + ], 138 + }); 139 + }); 140 + 141 + slackApp.action("make-account", async ({ context }) => { 142 + if (context?.respond) 143 + await context.respond({ 144 + response_type: "ephemeral", 145 + text: `great! your account has been created :yay:\n\nsign in at <https://waka.hackclub.com/login|hackatime> with your username \`${context.userId}\` and the password you just set up!`, 146 + }); 147 + }); 148 + 149 + slackApp.action("bad-info", async ({ context }) => { 150 + if (context?.respond) 151 + await context.respond({ 152 + response_type: "ephemeral", 153 + text: "no worries! we can't really change the `username` or `email` but you can change your `password` if you'd like! just re-run this command :3c:", 70 154 }); 71 155 }); 72 156 };
+1 -1
package.json
··· 14 14 "typescript": "^5.0.0" 15 15 }, 16 16 "dependencies": { 17 - "slack-edge": "^1.3.2" 17 + "slack-edge": "^1.3.7" 18 18 } 19 19 }