Login With Facebook After Registration - Meteor - angularjs

I am currently working on my first AngularJs + Meteor app. In this app, user can either register using $meteor.createUser or can use Facebook to login i.e. $meteor.loginWithFacebook. After logging in, on one page I am displaying user's friends from Facebook who have used this app. If user has logged in using Facebook then that page is working properly. But if user has registered using normal Meteor login [$meteor.createUser], then on that page I have to display Login with Facebook button. When user logs in with Facebook on this page, it is creating new document in users collection. But I am using Meteor.userId() as primary key in all tables. So I have following options:
Option 1:
delete current document of user [_id no 1]
log in with Facebook
change _id of a document created while logging
with facebook to _id no 1
Option 2:
Assign "_id no 1" to user while he registers using Facebook
But I have not found any way to do so. How to do it? I am not able to change _id of document present in users collection. Please help. Thank you in advance.

I think you have to merge those accounts. This package will be helpful:
https://atmospherejs.com/mikael/accounts-merge

Related

JHipster angularjs application - Want to perform the login operation with mobile number instead of username

I am new to jhipster, so I just created a jhipster application with angularjs and spring. I want to perform the login operation with mobile number instead of username. I have already created a mobile number field during registering new account but on login screen I am not able to find the query where I can change username with mobilenumber.
Basic monolithic app setup is made with yo jhipster.
Thanks in advance
You have to look at the implementation of UserDetailsService and replace how the user is being loaded. For example, change the below line to load user by mobile number.
Optional<User> userFromDatabase = userRepository.findOneWithAuthoritiesByLogin(lowercaseLogin);
You could also save the mobile number in existing login field. Then you do not need to change anything.

backand : issues with user creation, deletion, update

I'm creating an app using ionic/angularjs using Backand as the backend service. I have it setup to use a MySQL database.
1) When I create a user through the SDK (version 1.8.2 from the CDN), the user shows up in Registered Users area but does not get a row in the 'users' table. Someone mentioned that I should have Anonymous Access set to User as they said this is a permissions issue but that did not solve the issue for me.
2) I can manually add a user through the Backand GUI and the user gets a row in the 'users' table as I would expect.
3) I can not manually delete users or rows in the 'users' table through the Backand GUI. I get an error stating that the "Delete My App User" failed to perform. You can't specify target table 'users' for update in FROM clause. I haven't modified the Security Actions at all. They're all default. Updating a user receives a similar error.
4) I created a blank app in Backand and updated my app with the new tokens and app name. I was able to login to that app using login credentials that were created on the original app but were not a part of this app. Does this mean users can access any Backand once registered with one app on the system?
Am I just really missing how 'users' registration and logins are suppose to work in Backand?
Any guidance would be appreciated. Thank you in advance.
You can read more on the Back& security concept here.
User can only access to the app he was registred into. In your case I believe the second app has anonymus access, so you have signed in to the first app and got access token, and using the anonymus header you accessed the second app.
Please use incognito window mode for the second app and then you could debug two apps.
You can also review Back& User example to play around with the security.

DNN 7.4.2 Custom Registration / Login Module

I have DNN 7.4.2 installed. Besides standard registration/login I would also like to utilize Facebook,Twiiter,Windows Live, and Google authentication. However, I don't like the current workflow. I am now familiar using the Christoc templates to build custom modules, but is this what I want to do, or do I need to build a custom authentication provider. A lot of the examples out there reference old versions of DNN.
Here's the flow I want:
1) If User is not logged into site, check to see if they are logged into one of the social sites, and if so check their id to see if it is associated with a User on my site. If so, log them in automatically to my site.
2) If User is not logged in yet, display "Register" and "Login" Links on my menu.
3) If they click the "Register" link, a jquery popup should appear. Buttons for normal registration, and a button each for registering with one of the social sites should appear.
4) If they click on the regular registration, they should go directly to un-pre-populated registration form.
5) If they click on one of the social buttons, it should retrieve whatever info it can from the particular social site, and then go to the same registration form, but pre-populate the controls with the info it retrieved.
6) The registration form should have all the standard fields, plus a place for the avatar (which can be prepopulated from the pic retrieved from social site). In addition, I am using DISQUS comments, and so I want them to be able to enter their DISQUS login info and/or create a DISQUS account.
7) Once the user hits submit, only then is the User actually created. User should be returned to whatever page they were on when they started the registration process.
8) If User is not logged in, and they click "Login" link, a jquery popup will give them Username/Password controls if they want to login in standardly, and also have buttons for logging in with each of the social sites.
9) Id login is unsuccessful, jquery popup content would be replaced with "Unsuccessful" content, and content for retrieving lost usernames / passwords.
10) If login is successful, then they should also be logged into DISQUS.
If there is already a good module that will do all this, then I would prefer just to spend $100-$200 to get it. However, if there isn't, I would just like a push in the right direction on how to program all of this.
1) If User is not logged into site, check to see if they are logged
into one of the social sites, and if so check their id to see if it is
associated with a User on my site. If so, log them in automatically to
my site.
This point is unpossible. Every web page is isolated from each other. You can't determine that user is logged in or not in another webpage. Also you can't identify not logged user (in your website) to check if he is logged in with API (by userId).
I thnik all other points can be reached by this module: http://store.dnnsoftware.com/home/product-details/social-login-and-social-sharing.
While I thank Aram for his suggestion, I believe I am going to have to write my own custom authentication providers from scratch. I hate the fact that I could get no other responses. I also hate the fact that there is seemingly no good options for me to make a reasonable on-time module purchase to at least get something resembling what I need.

Role based authentication with firebase and angularjs

I am using email/password authentication via Firebase, so currently I only have authenticated user and non-authenticated user. But for the app, I would like to have admin, moderator, user and guest four different kinds of role.
I did some research, but could not find any existing example or logic to do so. Here are my initial thoughs, but not sure if it is feasible. Basically two steps:
Create a table in firebase called User, while Firebase record the email/password, I also push the data(email/password), and role information to the table.
In the route, check if the user has the appropriate role to access the certain page
Any other better way to do it? Any idea would be appreciated!
I had similar issue while working with role based authorization. I followed same pattern of saving users role and then retriving it when needed. If you are using ui-router for routes then probably you can use angular-permission module which works on the same concept and is easy to use.
You can find that module here: https://github.com/Narzerus/angular-permission

Get user name and basic detail without using facebook graph api

I am working on a website, I have one problem ..
I have facebook users id in my database, now I want to get their names using their ids but without using graph api..
Is there any way to do so..
I assume you want to do this programaticaly... Short answer is - you can't.
If you want to do it manually you can simply navigate to this url: https://facebook.com/profile.php?id={USERS_ID}It will give you the users profile page where you can see their name IF their profile is publicly available.
Essentially you should request the users names and store them in your database when the users authenticate your application.

Resources