So right now i got alot of ways to login to my app via facebook/google/github and more.
but the thing is that for each services i got almost the same data about me, especially the email address and right now for each services meteor creates new account and i was wondering how can i check to see if some user in my DB is already using a certain email (which is unique of course) and instead of creating a new user just extend the services object and if there is no such user yet then create it.(or similar)
(example of extending ):
(user clicks login via facebook):
{ "createdAt" : ISODate("2013-11-03T17:13:14.232Z"),
"_id" : "xxx", "services" : { "facebook" : { "accessToken" :xxx", "expiresAt" : xxx, "id" : "1841894180", "email" : "xxx", "name" : "Boaz Hoch", "first_name" : "Boaz"
and so on
then after logging out and login with google the user object will look like this:
{ "createdAt" : ISODate("2013-11-03T17:13:14.232Z"),
"_id" : "xxx", "services" : { "facebook" : { "accessToken" :xxx", "expiresAt" : xxx, "id" : "1841894180", "email" : "xxx", "name" : "Boaz Hoch", "first_name" : "Boaz" and more of facebook...} //end of facebook service, google:{ { "accessToken" :xxx", "expiresAt" : xxx, "id" : "1841894180", "email" : "xxx", "name" : "Boaz Hoch", "first_name" : "Boaz" and more
any best practice for this?
i think i have found what i was looking for, here:Using Meteor Accounts package to link multiple services
going to test it now see if its working.
after if tested it, seems to be working smooth!
Related
I have so many applications on my server who are using mongo db. I want to find out the user name which is being used to create specific db/collection.
I see some application is malfunctioning and keeps on creating dbs dynamically. I want to find out the application through the user which is being used.
What i have done so far is, i found out the connection information from the mongodb logs by grepping that database and then ran this query,
db.currentOp(true).inprog.forEach(function(o){if(o.connectionId == 502925 ) printjson(o)});
And this is the result i am getting,
{
"host" : "abcd-server:27017",
"desc" : "conn502925",
"connectionId" : 502925,
"client" : "127.0.0.1:39266",
"clientMetadata" : {
"driver" : {
"name" : "mongo-java-driver",
"version" : "3.6.4"
},
"os" : {
"type" : "Linux",
"name" : "Linux",
"architecture" : "amd64",
"version" : "3.10.0-862.14.4.el7.x86_64"
},
"platform" : "Java/AdoptOpenJDK/1.8.0_212-b03"
},
"active" : false,
"currentOpTime" : "2019-07-02T07:31:39.518-0500"
}
Please let me know if there is any way to find out the user.
I am working on an application and I need to move the Stripe payment data I have saved around in my user model. I am looking for the best way of doing this. My current data is stored at user.stripe.<value> but I want to move it to user.company.stripe.<value>
Is there tools out there that can handle moving this data around for me or will I need to create a tool to handle this myself? I will be doing a decent amount of this type of data movement during a major refactor (more like a rewrite) so making a tool if non exists is okay with me just no idea how to migrate the data and other Stack Overflow posts are not being of much use that I have found.
Probably picked a bad day/time to post too... Hopefully someone can help me out with examples or direction on where to go from here.
What I want the data to look like:
{ "_id" : ObjectId("5b89c571d855a23b5b07fe95"), "company" : { "customForms" : [ ], "subUserCount" : 1, "stripe" : { "plan" : "<plan Name>", "customerId" : "cus_<ID>", "last4" : "4242", "subscriptionId" : "sub<ID>", "isCoupon" : false } }, "email" : "john.doe#example.ca", "password" : "$2a$10$gMbdy5Dh9Ym..xbVAvhaJO2xhVARAL3oXvad/fX4zAcCuZB88tR1C", "role" : "company", "companyID" : "da89bdee-4123-444c-b221-d41212320a90", }
Current data format:
{ "_id" : ObjectId("5b89c571d855a23b5b07fe95"), "company" : { "customForms" : [ ], "subUserCount" : 1 }, "stripe" : { "plan" : "testplan2", "customerId" : "cus_<ID>", "last4" : "4242", "subscriptionId" : "sub_<ID>", "isCoupon" : false }, "isVerified" : true, "email" : "john.doe#example.ca", "password" : "$2a$10$gMbdy5Dh9Ym..xbVAvhaJO2xhVARAL3oXvad/fX4zAcCuZB88tR1C", "role" : "company", "companyID" : "da89bdee-4123-444c-b221-d41212320a90" }
I would like to ask that question. The question is how to get specific data range from firebase ?
I have table on firebase like this:
"users" : {
"Jz3IpatRWiWoDbiYM62q6qbHB503" : {
"email" : "Kaanozdemir#gmail.com",
"lastName" : "Ozdemir",
"name" : "Kaan"
},
"PmeYYFiac0c55fU2sFpnTP308mC3" : {
"email" : "kevinhart#gmail.com",
"lastName" : "Hart",
"name" : "Kevin"
},
"r0bMqSGCWihFi2EF4u6ckSzLP8v1" : {
"email" : "Marcusalvarez#gmail.com",
"lastName" : "Alvarez",
"name" : "Marcus"
},
"A3tmSSGCWihFi2EF4u6ckSzLP8c1" : {
"email" : "taylorswift#gmail.com",
"lastName" : "Swift",
"name" : "Taylor"
},
"3SUTsiGCWihFi2EF4u6ckSzLP8v2" : {
"email" : "jimmyfellon#gmail.com",
"lastName" : "Fellon",
"name" : "Jimmy"
},
"lgSit3GCWihFi2EF4u6ckSzLP8u3" : {
"email" : "jaxteller#gmail.com",
"lastName" : "Teller",
"name" : "Jax"
}
For example, I would like to get users values between 2 and 4 [2 - 4](Marcus Alvarez - Taylor Swift - Jimmy Fellon).
Is there any way to do that server side ? I don't wanna get all data and pick values that I want. Anyone knows?
Change your JSON DB structure to include an index in every node :
"users" : {
"autoID1" : {
"email" :.....,
"lastName" : ......,
"name" :.......,
"index" : //e.g.. 1,2,3,4......
}
},
"noOfUsers" : 223,
If you are appending this users node via app, you have too keep track of the no of users in Database node users and keep updating the noOfUsers whenever a new user is added. And to set the next ones index number , just retrieve that node value i.e 223 and sees it and then increment the noOfUsers......
To retrieve between 2-4 .. Now you can use :
Database.database().reference().child("users").queryOrdered(byChild: "index").queryStarting(atValue: "2").queryEnding(atValue: "4").observe....
I'm looking for a sample client implementation utilizing ALPS (not the mountains but the Application-Level Profile Semantics).
Do YOU! have one?
I've looked into the related RFC draft and discussions but still can figure it quite out.
Specifically I would like to know how my client should know what the descriptor describes, given that my client supposedly knows nothing about the structure and semantics of the REST API as the REST principle demands?
As a human I know that a descriptor with an id tag called "users" is likely to describe how to interact with users but how is my client to know without me telling him explicitly?
I know I could insert some kind of keyword to show up in the descriptor and tell my client to match the appropriate ones but this seems hardly the right way.
I happily provide a more detailed example given somebody is willing to read it.
I'm exploring ALPS for the first time too, and my understanding from that RFC draft wasn't immediate either.
Here is a slideshow (166 slides, so it's not possible to copy it all into this answer) from the author of the RFC which I think gives a much better understanding of the role ALPS plays.
As a human I know that a descriptor with an id tag called users is likely to describe how to interact with users but how is my client to know this without me telling him explicitly?
From this slideshow, I deduce this answer to your question: He doesn't.
In the slideshow, a sample ALPS profile is compared with equivalent HTML code for a form submit. The browser knows how to render the HTML to the screen, but only the human knows what it means to POST that form with those input fields, using that submit button.
Here is an example Complete JSON Representation taken from alps.io
{
"alps" : {
"version" : "1.0",
"doc" : {
"href" : "http://example.org/samples/full/doc.html"
},
"descriptor" : [
{
"id" : "search",
"type" : "safe",
"doc" : {"value" :
"A search form with a two inputs"
},
"descriptor" : [
{
"id" : "value",
"name" : "search",
"type" : "descriptor",
"doc" : { "value" : "input for search" }
},
{ "href" : "#resultType" }
]
},
{
"id" : "resultType",
"type" : "descriptor",
"description" : {"value" : "results format"},
"ext" : [
{
"href" : "http://alps.io/ext/range",
"value" : "summary,detail"
}
]
}
]
}
}
Take, for example, a generic mobile phone app which is displaying screens to the user based on REST responses. Say a HAL+Json response contains a reference to a search entity. The app can lookup in this ALPS document what a search entity is, and can be coded on how to represent that. Namely, a search is something which has a name/value pair (with an id) and a href. The href refers to the second descriptor with id resultType which lets the app know the format to expect for search results. The actual URLs and data involved would come from the REST responses.
From July 2014, here is a Spring blog article describing the ALPS for an app which manages a "To Do List". The ALPS document describes
What is a todo entity
What actions can be done with a todo entity
An abridged version of the ALPS profile for that small app:
{
"version" : "1.0",
"descriptors" : [ {
"id" : "todo-representation",
"descriptors" : [ {
"name" : "description",
"doc" : {
"value" : "Details about the TODO item",
"format" : "TEXT"
},
"type" : "SEMANTIC"
}, {
"name" : "title",
"doc" : {
"value" : "Title for the TODO item",
"format" : "TEXT"
},
"type" : "SEMANTIC"
}, {
"name" : "id",
"type" : "SEMANTIC"
}, {
"name" : "completed",
"doc" : {
"value" : "Is it completed?",
"format" : "TEXT"
},
"type" : "SEMANTIC"
} ]
}, {
"id" : "create-todos",
"name" : "todos",
"type" : "UNSAFE",
"rt" : "#todo-representation"
}, {
"id" : "get-todos",
"name" : "todos",
"type" : "SAFE",
"rt" : "#todo-representation"
}, {
"id" : "delete-todo",
"name" : "todo",
"type" : "IDEMPOTENT",
"rt" : "#todo-representation"
} ]
}
I guess one way to think of it might as a kind "schema", but instead of database tables, it's describing the scope of REST responses.
My application has both facebook and twitter users. Now users can merge two accounts together which means they can login with either facebook or twitter account.
Right now, I have a model like this.
{ "_id" : ObjectId("51103a3e69931d2f03000001"), "email" : "email", "id" : "twitter_id", "token" : "token", "secret" : "secret"}
{ "_id" : ObjectId("51103a3e69931d2f03000001"), "email" : "email", "id" : "facebook_id", "token" : "token", "secret" : ""}
Now if these two accounts are the same and the user decided to merge or connect one of his account to something else. How should I change this model effectively and performance as well. I am thinking of having another object called
{"linked_ids" : ["facebook_id", "linkedin_id" ]}
in both accounts. So, the data would be like this. Once merged.
{ "_id" : ObjectId("51103a3e69931d2f03000001"), "email" : "email", "id" : "twitter_id", "token" : "token", "secret" : "secret", "linked_id" : ["facebook_id"] }
{ "_id" : ObjectId("51103a3e69931d2f03000001"), "email" : "email", "id" : "facebook_id", "token" : "token", "secret" : "", "linked_id" : ["twitter_id"] }
Not sure if this would be the best way for performance and scalability?
Why not have one user document in a user collection from the start? You could model it this way instead:
{
"_id" : ObjectId("..."),
"username" : "bob123",
"accounts" : [
{
"email": "email",
"id": "twitter_id",
"token": "token",
"secret": "secret",
"type" : "Twitter"
},
{
"email": "email",
"id": "facebook_id",
"token": "token",
"secret": "",
"type" : "Facebook"
}
]
}
Mongo has plenty of operations to deal with arrays. You can add to them, update one item in the array only, etc.
Doing joins with Mongo introduces complexity that it isn't good at handling as of now. You'd have to do that "join" in your application.
Also this model means you can add any other forms of authentication in one document.