Creating a User model for Facebook login - facebook-login

I'm trying to User model and add in some necessary fields that Omniauth uses for user authentication.
Run the following command from terminal:
rails g model User provider uid name oauth_token oauth_expires_at:datetime
but I'm getting an error message saying that
invoke active_record
The name 'User' is either already used in your application or reserved by Ruby on Rails.Please chose an alternative and run this generator again.

seems like you already have the app/models/user.rb file in your project and the rails generator complains about that

Related

Django - how to set user permissions after login via LDAP?

I'm starting a project in Django and I've already managed to get ldap authentication working, with django-auth-ldap.
Now, I want that after the user logs in, django checks if this user exists in certain tables of my models, and if it does, give these users permission to access certain apps.
For example, I have an app called 'alimentacao'. Only users registered in my model 'alimentacao.alunos' will be able to access "http://meu-projeto/alimentacao"
As the user is created automatically if it doesn't already exist in the user model, I believe I would have to create a custom ldap authentication backend and check, after successful login, if the user exists in the table, and then set the permission to user.
Neither the Django nor the django-auth-ldap documentation clearly explains how to create an authentication backend: in which folders the files need to be created, or how the application will call my custom method, or if I need to change any settings. I'm completely lost.

User Data Posted to Django User Model API Fails Authentication

I have two deployed Django projects: A and B and both have User models for user authentication. But I want users of Project B who sign up to have accounts on Project A as well. So I created an API using DRF for the user model in Project A and I was able to post user data (username and password) from Project B to the API.
But when I tried to login to Project A using the newly posted user data, it failed authentication, despite the data now bring present in Project A's API. Please could anyone help me identify what's wrong?

How do I get Django 1.5 Custom User Model and Social Auth to work?

Django Social Auth (0.7.22) is reported to support Custom User Models but I have no been able to get this to work.
In my case I am using Google's Oauth2 which I have working with a non-custom-user-model.
With the Custom User Model I get correctly redirected to the Google Account Page, select an account to login and then and redirected to the LOGIN_ERROR_URL, with no messages or debug info.
To simplify debugging I have created a simple example project with the bare minimum bits and pieces at https://github.com/jonathanendersby/SocialAuthCustomUserModel
Has anyone got this to work and can they point out where I have gone wrong?
This issue is now resolved in the repo at https://github.com/jonathanendersby/SocialAuthCustomUserModel
Quoting https://github.com/omab:
The problem was the parameters that create_user() was getting, not all
of them are available on all the backends.
By replacing the method signature with the same from django manager,
and setting some default values into first_name and last_name fields
in your model, it works OK.

django user to be populated in LDAP

I would like when a user creates an account in Django, that the user information :
- Username
- Password
- Email
- First and Last Name
- Mobile
Gets also populated in my LDAP server. Also when the user get deactivated, this gets reflected in LDAP.
Authentication will still be done in Django.
I need the user information as i have another application which is getting the user info from LDAP. I need both to be have the same user universe.
Are there any snippet that does that already ?
I saw many code to authenticate thourgh LDAP, but what i really need is to populate the LDAP directory with my Django user on the fly
Thanks for your help
Check out this snippet, it should do exactly what you're after (a bit old though, so YMMV with newer django)

How can I add user profile support to a google app engine app?

I have a Google App Engine app based on django / django_appengine that I wish to modify by adding user profile support to it, because the basic user model is a bit simplistic for my situation.
What's the best way to do this?
You can create a Model called for example UserProfile which has as its key a user's email address or user ID.
UserProfile profile = UserProfile.get_or_create(user.user_id) will make sure that no user profiles are created for existing user IDs.