Extract valid email util
This commit is contained in:
parent
b841cec4c9
commit
c0d7f2329a
|
@ -1,6 +1,7 @@
|
|||
import fetch from "node-fetch"
|
||||
import * as sso from "./sso"
|
||||
import { ssoCallbackUrl } from "../utils"
|
||||
import { validEmail } from "../../../utils"
|
||||
import {
|
||||
ConfigType,
|
||||
OIDCInnerConfig,
|
||||
|
@ -11,6 +12,7 @@ import {
|
|||
JwtClaims,
|
||||
SaveSSOUserFunction,
|
||||
} from "@budibase/types"
|
||||
|
||||
const OIDCStrategy = require("@techpass/passport-openidconnect").Strategy
|
||||
|
||||
export function buildVerifyFn(saveUserFn: SaveSSOUserFunction) {
|
||||
|
@ -86,15 +88,6 @@ function getEmail(profile: SSOProfile, jwtClaims: JwtClaims) {
|
|||
)
|
||||
}
|
||||
|
||||
function validEmail(value: string) {
|
||||
return (
|
||||
value &&
|
||||
!!value.match(
|
||||
/^(([^<>()[\]\\.,;:\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,}))$/
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the oidc passport strategy. This wrapper fetches the configuration
|
||||
* from couchDB rather than environment variables, using this factory is necessary for dynamically configuring passport.
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
export * from "./hashing"
|
||||
export * from "./utils"
|
||||
export * from "./stringUtils"
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
export function validEmail(value: string) {
|
||||
return (
|
||||
value &&
|
||||
!!value.match(
|
||||
/^(([^<>()[\]\\.,;:\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,}))$/
|
||||
)
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue