Skip to content

Instantly share code, notes, and snippets.

@gristoi
gristoi / machine.js
Created August 20, 2021 11:06
Generated by XState Viz: https://xstate.js.org/viz
const initialContext = { username: '', password: '', jwt: '' }
// taken from https://www.w3resource.com/javascript/form/email-validation.php
const emailReg = /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/
// taken from https://stackoverflow.com/questions/19605150/regex-for-password-must-contain-at-least-eight-characters-at-least-one-number-a
const passwordReg = /^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,}$/
function mockAuthenticate(username, password, ms = 1500) {
return new Promise((resolve, reject) => {
setTimeout(() => {