Code Monkey home page Code Monkey logo

Comments (4)

DeanKamali avatar DeanKamali commented on June 14, 2024 2

@odesey

Meteor.user() will retrieve logged in user document from meteor's user collection, I guess what you are looking for is creating a reactive object after user is logged in:

based on the previous example, after successful auth, you will have access to server.userId, you can then create a reactive object like so:

if (server.userId) {
  let userReactiveCursor = server.collection('users').filter(user=>user.id==server.userId).reactive().one();
  let userReactiveObject = userReactiveCursor.data(); // userReactiveObject is equivalent to `Meteor.user()`
}

from simpleddp.

DeanKamali avatar DeanKamali commented on June 14, 2024

According to docs, simpleDDP.login(auth) the function returns a Promise which resolves to the object with userId of the logged-in user when the login succeeds or rejects when it fails.

Here is an example:

server.userId; // undefined, we are not logged in

let password = "somepassword";
let username = "admin";
let email = "admin@admin";

// you must pass password and at least one of username or email
let userAuth = await server.login({
  password,
  user: {
      username,
      email
  }
});

server.userId; // now equals to 'd6PqCAKk2QZeqZHWy'
server.token; // now equals to 'N50Gmknk__geP63YD9pHKdl07b8XXxNGpB_cz5Lte4d'

Hope this helps

from simpleddp.

odesey avatar odesey commented on June 14, 2024

Thanks for the quick response @DeanKamali

So I guess I will have to implement my own Meteor.user() subscription or method in order to get the user's data once they are logged in?

Thanks.

from simpleddp.

odesey avatar odesey commented on June 14, 2024

Thanks for your help @DeanKamali , I was able to get this working in my react-native app.

from simpleddp.

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.