Giter Club home page Giter Club logo

tivix / angular-django-registration-auth Goto Github PK

View Code? Open in Web Editor NEW
202.0 80.0 52.0 166 KB

This AngularJS module is designed to provide an authentication interface between a SPA (single page app), and a Django application running the Django REST Auth app. In addition to providing a client-side API, this module includes pages to support authentication and user profiles right out of the box.

Home Page: http://www.tivix.com

JavaScript 47.34% CSS 1.66% ApacheConf 28.47% HTML 22.52%

angular-django-registration-auth's Introduction

AngularJS Module for Django REST Auth

To setup this module as a boilerplate project...

First, clone the repository:

git clone [email protected]:Tivix/angular-django-registration-auth.git

Change your directory to the cloned project:

cd angular-django-registration-auth

Then, install the project prerequisites:

npm install; bower install;

Customize API_URL and use_session to meet your project's requirements:

Go to app/scripts/services/djangoAuth.js

If using django-rest-auth demo, check out the docs for a list of endpoints:

http://django-rest-auth.readthedocs.org/en/latest/api_endpoints.html

Then, serve the Angular Django Registration Auth Demo:

grunt serve

To integrate this module into an existing project...

First, clone the repository:

git clone [email protected]:Tivix/angular-django-registration-auth.git

The contents of the app/scripts folder can be copied to your own project.
Exclude controllers and app.js if you do not intend to use the default views/routes. (This will provide API access from the djangoAuth module only.)

Inject the angularDjangoRegistrationAuthApp into your own module.
Inject the djangoAuth service into any controllers in which you need programmatic access to Django REST Auth.
Customize API_URL and use_session to meet your project's requirements:

Go to app/scripts/services/djangoAuth.js Alternatively, you can change these settings from a controller by changing the djangoAuth.API_URL and djangoAuth.use_session variables.

Please note:

you will need to include dependencies from bower.json to support the default views/controllers. They require bootstrap and its dependencies to function correctly. If you intend to use the default views/routes, copy the contents of app/views to your own views folder.

Todo: We encourage contributions for these aims...

  • Add support for JWT (JSON web tokens)

  • Better support for Bower and Grunt

  • Pick a better name for the module?

angular-django-registration-auth's People

Contributors

linuxlewis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-django-registration-auth's Issues

When running "grunt serve", some script resources could not be found because of case-sensitive file system

Invalid token

I'm having a strange issue, most likely just some incorrect setup.

Initially I was having issues getting it working with gulp as my task runner, where using grunt works just fine. But if I run grunt build and then serve up the content from the dist folder, I get a 401 error when trying to log in. Server response is detail: "Invalid token".

When loading the main page and attempting to log in, my console contains the following:

GET http://127.0.0.1:8000/rest-auth/user/ 403 (FORBIDDEN) angular.js:8380
error syncing with: //127.0.0.1:8000/rest-auth/user/ 9d7fcc59.scripts.js:1
POST http://127.0.0.1:8000/rest-auth/login/ 401 (UNAUTHORIZED) angular.js:8380
error syncing with: //127.0.0.1:8000/rest-auth/login/ 9d7fcc59.scripts.js:1

Which is pretty much the same thing I'm getting when serving the content via gulp, except the line numbers are of more use since the js isn't minified:

GET http://127.0.0.1:8000/rest-auth/user/ 403 (FORBIDDEN) angular.js:8561
error syncing with: http://127.0.0.1:8000/rest-auth/user/ djangoAuth.js:43
POST http://127.0.0.1:8000/rest-auth/login/ 401 (UNAUTHORIZED) 127.0.0.1:8000/rest-auth/login/:1
error syncing with: http://127.0.0.1:8000/rest-auth/login/ djangoAuth.js:43

Any help would be very much appreciated.

cross site request not allowed (csrf)

I am evaluating angular-django-registration-auth in conjunction with django-rest-auth.
When I try to call the login API within angular-django-registration-auth I get the UI error: "Could not connect. Please try again."
Locking into the browser console I see:
XMLHttpRequest cannot load http://127.0.0.1:8000/rest-auth/login/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:9002' is therefore not allowed access.
djangoAuth.js:43 error syncing with: http://127.0.0.1:8000/rest-auth/login/

the response header looks like:
HTTP/1.0 200 OK
Date: Fri, 23 Jan 2015 10:27:25 GMT
Server: WSGIServer/0.1 Python/2.7.6
Vary: Accept, Cookie
X-Frame-Options: SAMEORIGIN
Content-Type: application/json
Allow: POST, OPTIONS

I guess this has something to do with csrf but I cannot figure out what I need to change either in the client $http request or on django view site.
Besides, using the browseable API of DRF it works.

Any clues, ideas what I should look for?
BR

Unable to register new user

I am encountering issues when trying to register a new user.

I believe the first issue is that the docs for the server app specify the rest_uath.registration urls as:

urlpatterns = patterns('',
    ...,
    (r'^rest-auth/', include('rest_auth.urls'))
    (r'^rest-auth/registration/', include('rest_auth.registration.urls'))
)

While the angular client is trying to connect to rest-auth/register/ - link to code

Even after fixing that I'm still having issues though. It seems the api endpoint is expecting some parameters that the front-end isn't sending: password1 and password2.

Unauthorized 401 when loading the page

Hi, implement angular-django-registration-auth but when I load the page a popup is displayed asking me for authentication and when I click cancel an error is displayed: http://127.0.0.1:8000/rest-auth/user Failed to load resource: the server responded with a status of 401 (UNAUTHORIZED)

I clear the cookies and It still is displayed. In django settings REST_FRAMEWORK I have:

'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly' (here I tried with anothers like AllowAny, IsAuthenticatedOrReadOnly and DjangoModelPermissions with all of them I get the same result)
],
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.BaseicAuthentication',
'rest_framework.authentication.SessionAuthentication'
]

Is it an issue? or have I something wrong?

please advise

Custom User model support in registration/login API endpoints

It looks like custom user model is not supported by default within django-rest-auth.

I've implemented a custom user model that do not have a username. USERNAME_FIELD is set to 'email'. When I access to /rest-auth/registration URI, I see that username is a mandatory field.

Shouldn't there be a mechanism to build the serializer dynamically based on the user model set with settings.AUTH_USER_MODEL as it is performed with django-allauth?

Is there any way to workaround this issue?

Thanks

GET method not working.

Hi,

I have set this repo up including the routes and all is working fine except the GET method.

I am able to POST successfully, receiving status 200 from the server each time when I log in. However when I want to retreive "/user/", it responds that "Authentication credentials were not provided" with a 403, even though the token has been recieved and is stored locally.

I logged $http.defaults.headers and there is no GET method in the headers, I'm not sure whether that is intentional or not.

npm install fails on gifsicle

npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v6.10.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! [email protected] postinstall: node index.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'node index.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the gifsicle package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node index.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs gifsicle
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls gifsicle
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:

npm-debug.log.txt

NoReverseMatch at /rest-auth/password/reset/ Reverse for 'password_reset_confirm' with arguments '()' and keyword arguments...

Hi,

I'm running into an issue using django-rest-auth with angular-django-registration-auth. I'm using django 1.8.1 and am getting the following when I send request a password reset:

NoReverseMatch at /rest-auth/password/reset/
Reverse for 'password_reset_confirm' with arguments '()' and keyword arguments

the following line is the culprit in the template, site-packages/django/contrib/admin/templates/registration/password_reset_email.html

 {% url 'password_reset_confirm' uidb64=uid token=token %}

Any help is greatly appreciated.

Module 'angularDjangoRegistrationAuthApp' is not available

I am trying to inject angularDjangoRegistrationAuthApp into my app, and have tried a number of things too naive to mention. I continue to get the same javascript error:

Uncaught Error: [$injector:modulerr] Failed to instantiate module angularDjangoRegistrationAuthApp due to: Error: [$injector:nomod] Module 'angularDjangoRegistrationAuthApp' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.2.16/$injector/nomod?p0=angularDjangoRegistrationAuthApp

Can you suggest with an example how the app (module?) injection might be implemented?

Thank you,
Thomas Grzybowski

ngCookies - Cookie Methods Different for Angular 1.4 +

Hi -

Thanks for open sourcing this time saver.

I noticed the cookie methods in djangoAuth.js need to be updated for later versions of angular

delete $cookies.token;
changes to:
$cookies.remove('token');

$cookies.token
changes to:
$cookies.get('token')

$cookies.token = data.key;
changes to:
$cookies.put("token", data.key);

Not sure if the this project is still active but thought I'd make a note here if someone wants to try this with a newer version of angular.

Angular 2

Any chance of this being ported to Angular 2?

Must include "email" and "password". HTTP 400

After registering a user, I can't login with that user - neither on the AngularJS app nor the JQuery demo app.

API Response: 400 BAD REQUEST
Content: {"non_field_errors":["Must include "email" and "password"."]}

The user's email has been verified... I did enable CORS in settings.py (as suggested here - #11) and it works (angular (9000) can talk to Django on 8000. However, I can't sign in using the demo app either (Django on 9000).

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.