Giter Site home page Giter Site logo

Comments (10)

cecilia-sanare avatar cecilia-sanare commented on June 21, 2024 1

@sharmapukar217 That's used to store the token and determine if the user is still authenticated (and refresh their authentication).

There are two alternative storage methods via localStorage and sessionStorage that you can utilize as well.

const auth = new SalteAuth({
    // ...
    storage: 'session', // Every time the browser is closed the user session will be destroyed
    storage: 'local' // Retains the user session even when the browser is closed (could still expire ofc)
});

from salte-auth.

cecilia-sanare avatar cecilia-sanare commented on June 21, 2024

By database are you referring to the browser's built-in database IndexedDB?
If so we never added support for it, unfortunately.

salte-auth and all of its sub-projects are effectively in maintenance mode at the moment and as such new features aren't really being implemented.

I'll keep this issue open as a way of tracking support regardless however :3

from salte-auth.

sharmapukar217 avatar sharmapukar217 commented on June 21, 2024

I'm not talking about indexed db. Taking reference from next-auth, i was wondering if this is possible or not, or maybe is it good to do so:
See this flow => "User clicks the button and we collect the required data but don't save to cookies, instead we save to our own database (real database on server) and handle all other authentication stuffs like generating session tokens on our own"

from salte-auth.

cecilia-sanare avatar cecilia-sanare commented on June 21, 2024

@sharmapukar217 Ahh!! We don’t have support for server side frameworks which we’re currently tracking over in #546. Best you could do is run the auth client-side and make a request to an api endpoint to save the data, but obviously that’s not ideal.

I’d recommend checking out next-auth if you haven’t already.

from salte-auth.

cecilia-sanare avatar cecilia-sanare commented on June 21, 2024

Duplicate of #546

from salte-auth.

sharmapukar217 avatar sharmapukar217 commented on June 21, 2024

No no.. i don't want to integrate with nextjs or any other framework at all. What I want is instead of saving the credentials to cookie directly, i want to process the data returned from social login and then send it to my auth server and return the user + token.
I have my own authentication system and I just want some helper library to implement the social login.

from salte-auth.

sharmapukar217 avatar sharmapukar217 commented on June 21, 2024

@sharmapukar217 Ahh!! Best you could do is run the auth client-side and make a request to an api endpoint to save the data, but obviously that’s not ideal.

Isn't it good to do so?? This is exactly what i wanted...

from salte-auth.

cecilia-sanare avatar cecilia-sanare commented on June 21, 2024

Sorry about the misunderstanding, I read next-auth in your comment and for some reason my brain just opted out of reading the next part of that.

So to clarify, you effectively want to have users login (as an example) with GitHub, Google, etc. and have it all tie back to an individual user in the backend, correct?

If that's the case you can handle it a few different ways. If you're okay with using an existing IDP like Auth0 you could use their service which would tie it all together for you then utilize the login event to store user info in your database.

Or if you'd rather roll your own solution for cost purposes you could add providers for each of the services you need and hook into the same login event and tie it all together in the backend using the user's email. That would be the best method off the top of my head.

const auth = new SalteAuth({
    providers: [
        new Google({
            clientID: '<client-id>',
            responseType: 'code',
        })
    ]
});

auth.on('login', (error, {provider, data}) => {
    // This will output 'google' in this case, but it'll be the name of your provider.
    console.log(provider);
    // This returns a UserInfo object (https://salte-auth.github.io/interfaces/utils_id_token.idtoken.userinfo.html)
    console.log(data);
});

from salte-auth.

sharmapukar217 avatar sharmapukar217 commented on June 21, 2024

Oh ok i think this one will work out for me. Thank you 🙂

from salte-auth.

sharmapukar217 avatar sharmapukar217 commented on June 21, 2024

It will be better i guess if you add an option on config to set cookies or not

from salte-auth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.