1 Reply Latest reply on Oct 31, 2012 10:17 AM by Adam Blum

    filtrate query by user loggedin

      Hello!

      how can i do, if i want to diplay records only for an user . i want to use .net plugin but i don't know how to send to the server what user is logged in to make a query (CRUD) only for that user.

        • Re: filtrate query by user loggedin

          Hook into the authenticate shown at: http://docs.rhomobile.com/rhoconnect/authentication:

           

          def authenticate(username, password, session)

            success = false

            # ... connect to backend using API and authenticate ...

            result = do_custom_authentication(username,password)

            if result.code == 200

              # save the data for later use in the source adapter


              Store.put_value("username:#{username}:token",result.body)

           

              success = true

            end

            return success

          end

           

          Then from your query source adapter you can use that stored user.

           

          If you mean from source adapter-less scenario (plugin only), that really depends on your backend app. You could presumably add appropriate calls from the authenticate method above to your backend .NET app to inform them of logged in users.  But there are presumably more than one logged in user.   How your backend app services all of those users really depends on how you have built your app. If it is stateful you presumably need to set up states for each of your authenticated users.   For example, your plugin may need to make multiple calls back to RhoConnect for each logged in user, servicing some kind of set of users that is set up by those authenticate calls.