How to use the next-auth/client.NextAuth.signin function in next-auth

To help you get started, we’ve selected a few next-auth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github iaincollins / next-auth / example / pages / auth / credentials.js View on Github external
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.")
    })
  }
github iaincollins / nextjs-starter / components / signin.js View on Github external
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}`)
    })
  }
github iaincollins / next-auth / example / pages / auth / index.js View on Github external
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}`)
    })
  }
github datavis-tech / vizhub-legacy / packages / web / components / molecules / signIn.js View on Github external
signInAsCI(event) {
    const email = 'ci@foo.com';
    const password = 'ci';
    
    NextAuth.signin({email, password})
      .then(authenticated => {
        Router.push(`/auth/callback`)
      });
  }