Giter Site home page Giter Site logo

Comments (3)

am-MongoDB avatar am-MongoDB commented on May 22, 2024 1

Hi @rubengarciam.

Custom user data is a useful feature but it has some limitations. On the Atlas side, it's a collection where each document is linked to a specific user. When a user authenticates in the frontend, the app gets a copy of the document as part of their user token. The frontend copy is read-only, and only gets updated to reflect Atlas when you re-login or after a period of time (30 minutes if I recall).

In O-FISH, the users are registered and setup by an administrator using a web app – so there's no need for the frontend app to modify the user data. That made custom data a good fit.

In RChat, the users register and setup their profile data in the frontend and so the read-only custom data option wouldn't work.

from rchat.

am-MongoDB avatar am-MongoDB commented on May 22, 2024

Hi @rubengarciam – that's a good question.

I've another Realm app that I think includes the behavior that you're looking for.

The top-level view checks if the user is already logged in, and if they are it continues as that user:

if settings.realmUser == nil && app.currentUser()?.state == .loggedIn {
    print("Using same user as when last running the app")
    settings.realmUser = app.currentUser()
}

It also uses face-id to store and retrieve the credentials in the keychain – see the app's LoginView:

...
if let error = self.keychain.addCredentials(Credentials(username: username, password: password)) as? KeychainError {
    print(error.localizedDescription)
}
...
private func getStoredCredentials() {
    let data = keychain.readCredentials()
    if let credentials = data.credentials {
        self.login(username: credentials.username, password: credentials.password)
    }

    if let error = data.error as? KeychainError {
        self.errorMessage = error.localizedDescription
    }
}

I hope this helps!

If you want to followup further, it would be great if you could create a topic on https://developer.mongodb.com/community/forums/c/realm/9 as it will get more eyeballs there – including from the SDK developers. Just tag me (@Andrew_Morgan) and add a link to your new topic to this issue.

from rchat.

rubengarciam avatar rubengarciam commented on May 22, 2024

Thanks @am-MongoDB for sharing! After having a look at them I think that both have different data models and that raises some additional questions on my head, like why you are user a custom User object in RChat vs Realm.User in o-fish-ios? The former seems somewhat cleaner in my eyes, even though AppState and Settings serve a similar purpose.

Might be my lack of knowledge in the matter though. Happy to do some further reading if you can point me in the right direction.

I will create the topic in the community forum anyway.

from rchat.

Related Issues (11)

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.