Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleSignInSubmit(event) {
event.preventDefault()
// An object passed NextAuth.signin will be passed to your signin() function
NextAuth.signin({
email: this.state.email,
password: this.state.password
})
.then(authenticated => {
Router.push(`/auth/callback`)
})
.catch(() => {
alert("Authentication failed.")
})
}
handleSubmit(event) {
event.preventDefault()
if (!this.state.email) return
this.setState({
submitting: true
})
// Save current URL so user is redirected back here after signing in
const cookies = new Cookies()
cookies.set('redirect_url', window.location.pathname, { path: '/' })
NextAuth.signin(this.state.email)
.then(() => {
Router.push(`/auth/check-email?email=${this.state.email}`)
})
.catch(err => {
Router.push(`/auth/error?action=signin&type=email&email=${this.state.email}`)
})
}
handleSignInSubmit(event) {
event.preventDefault()
if (!this.state.email) return
NextAuth.signin(this.state.email)
.then(() => {
Router.push(`/auth/check-email?email=${this.state.email}`)
})
.catch(() => {
Router.push(`/auth/error?action=signin&type=email&email=${this.state.email}`)
})
}
signInAsCI(event) {
const email = 'ci@foo.com';
const password = 'ci';
NextAuth.signin({email, password})
.then(authenticated => {
Router.push(`/auth/callback`)
});
}