refactor: improvements to the auth implementation in admin dashboard (#3444)
* refactor: abstract axios queries to a separate helper file * chore: delete unnecessary file * chore: remove unnecessary console logs * refactor: updated urls for api and authquery helpers * refactor: updated auth implementation * refactor: use default axios instance * chore: improve code readability * refactor: separate instances for rest and gql calls * refactor: removed async await from functions that do not need them * refactor: removed probable login and probable user from the auth system * refactor: better error handling in login component * chore: deleted unnecessary files and restructured some files * feat: new errors file with typed error message formats * refactor: removed unwanted usage of async await * refactor: optimizing the usage and return of promises in auth flow * refactor: convey boolean return type in a better way * chore: apply suggestions * refactor: handle case when mailcatcher is not active --------- Co-authored-by: nivedin <nivedinp@gmail.com> Co-authored-by: James George <jamesgeorge998001@gmail.com>
This commit is contained in:
committed by
GitHub
parent
46caf9b198
commit
7a9f0c8756
16
packages/hoppscotch-sh-admin/src/helpers/Email.ts
Normal file
16
packages/hoppscotch-sh-admin/src/helpers/Email.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import * as t from "io-ts"
|
||||
|
||||
const emailRegex =
|
||||
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
||||
|
||||
interface EmailBrand {
|
||||
readonly Email: unique symbol
|
||||
}
|
||||
|
||||
export const EmailCodec = t.brand(
|
||||
t.string,
|
||||
(x): x is t.Branded<string, EmailBrand> => emailRegex.test(x),
|
||||
"Email"
|
||||
)
|
||||
|
||||
export type Email = t.TypeOf<typeof EmailCodec>
|
||||
Reference in New Issue
Block a user