Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Lynn Dylan Hurley
    @lynndylanhurley
    I see a reference to PubSub - was that imported and everything?
    Nícolas Iensen
    @nicolasiensen
    oh, you are right
    console.log(Auth.configure) returned [Function]
    Lynn Dylan Hurley
    @lynndylanhurley
    oh cool, so the issue must be within the argument to Auth.configure
    Nícolas Iensen
    @nicolasiensen
    I tried to call Auth.configure({}) and got the same error
    Lynn Dylan Hurley
    @lynndylanhurley
    oh I see, I misread the error
    it’s saying that there is an error on line 309 of the j-toker dist file
    Nícolas Iensen
    @nicolasiensen
    yep
    Lynn Dylan Hurley
    @lynndylanhurley
    which is this:
          // save config to `configs` hash
          this.configs[configName] = $.extend(
            {}, this.configBase, opts[i][configName]
          );
    it looks like the extend method is throwing the error
    Nícolas Iensen
    @nicolasiensen
    hm
    i have jquery 2.1.4 installed
    Lynn Dylan Hurley
    @lynndylanhurley
    can you throw this log into line 299 of dist/jquery.j-toker.js:
    console.log("@-->$", $);
    I just want to make sure that jQuery is defined correctly
    Nícolas Iensen
    @nicolasiensen
    @-->$ function ( w ) {
    [1]                 if ( !w.document ) {
    [1]                     throw new Error( "jQuery requires a window with a document" );
    [1]                 }
    [1]                 return factory( w );
    [1]             }
    Lynn Dylan Hurley
    @lynndylanhurley
    well that looks right
    wait are you trying to use j-toker server-side?
    Nícolas Iensen
    @nicolasiensen
    yep
    Lynn Dylan Hurley
    @lynndylanhurley
    ok I didn’t understand that
    Nícolas Iensen
    @nicolasiensen
    we should have some kind of conditional to check if it’s client
    Lynn Dylan Hurley
    @lynndylanhurley
    will jQuery even let you make ajax calls server side?
    Nícolas Iensen
    @nicolasiensen
    I didn’t tried it yet
    Lynn Dylan Hurley
    @lynndylanhurley
    I’m not 100% clear on the use-case, but some of the features require a browser
    oAuth sign in for example
    and there’s a lot of reliance on cookies / localStorage for session persistance
    that will need to be modified for a server-side environment
    Nícolas Iensen
    @nicolasiensen
    I see
    Lynn Dylan Hurley
    @lynndylanhurley
    can you please post an issue on the j-toker tracker that defines your use-case? this is a situation that I hadn’t prepared for
    Nícolas Iensen
    @nicolasiensen
    I’m in the middle of a transition to the server-side rendering
    I’m not familiarized with this architecture yet
    Lynn Dylan Hurley
    @lynndylanhurley
    there may be a way to accomodate for that, but it may depend on things that are specific to your environment
    for example, if the server that is doing the rendering has access to the DB, then you shouldn’t need to make any AJAX calls for the user because you can just retrieve the data directly from the DB
    and all of the cookie / localStorage stuff would need to be handled completely differently in that context
    Nícolas Iensen
    @nicolasiensen
    yeah, I’ll keep doing this transition to server-side rendering and keep you in touch if I find anything new
    thanks anyway!
    Lynn Dylan Hurley
    @lynndylanhurley
    np!
    Nícolas Iensen
    @nicolasiensen
    hey @lynndylanhurley are you there?
    Nícolas Iensen
    @nicolasiensen
    @lynndylanhurley I’m implementing my own solution for the client-side user authentication, but I want to keep devise-token-auth in the server side. So I have two questions for you 1) I’ve noticed that every time I login, devise-token-auth creates a new key/value into the User#tokens attribute, is that right? Shouldn’t it update a key/value based on the client the user is logging in? 2) how j-toker takes the token back? devise-token-auth is not passing this token through the user’s json data, and I didn’t found it in the header of the response. Thanks a lot!
    Nícolas Iensen
    @nicolasiensen
    Hmm I found the answer for the 2o question
    Nícolas Iensen
    @nicolasiensen
    Hey @lynndylanhurley I have a question about devise_token_auth: how j-toker persists the logged in user between tabs or page refresh? The default seems to be cookies, right? So how j-toker fetches the logged in user based on cookies from the devise-token-auth? Is there an action in devise_token_auth for returning the logged in user based on the cookies? Thanks!
    Lynn Dylan Hurley
    @lynndylanhurley
    @nicolasiensen - when a user logs in, the response will contain an auth token. the auth token is stored as a cookie / localStorage value in the browser. This value will be included in requests to the API.
    So the server doesn’t have anything to do with the cookie. It only cares about the auth token that is included as a header in each request
    Nícolas Iensen
    @nicolasiensen
    hm, ok so in the Rails API there is nothing being kept by session, right?
    I’m implementing an server-side rendered app now, that uses devise-token-auth for login. I need to know if the user is logged in or not in the server-side-render time, but when server is rendering the app it doesn’t have access to the localStorage
    Nícolas Iensen
    @nicolasiensen
    so what do you suggest to make the current user available in the server-side rendering time?
    Kelly Summerlin
    @ksummerlin
    It might be worth mentioning in the docs somewhere that j-Toker will send the headers back only for API requests that match the auth.getApiUrl(). We setup the devise token gem at <root>/api/v1, but the rest of our web API is at <root>. It took us a little while to determine that the appendAuthHeaders was matching to the auth URL only.
    Once we figured that out, we just changed the auth.configure() to be '/' and then manually set all the config '*Path' properties accordingly using '/api/v1/auth/*'. That seems to work OK. But it definitely wasn't pit of success material.
    Norberto Oliveira Junior
    @norbajunior
    Hello guys. Could you help me? How do I include a custom header for the requests? I already tried this code below, but without success.
    $.ajaxSetup({
      beforeSend(xhr, settings) {
        xhr.setRequestHeader('HTTP-CUSTOM-HEADER', 'some-value')
    
        Auth.appendAuthHeaders(xhr, settings)
      }
    })