Coder Social home page Coder Social logo

colthreepv / angular-login-example Goto Github PK

View Code? Open in Web Editor NEW
522.0 522.0 172.0 2.03 MB

Stand-alone project showing how to make a robust angular application serving access permissions from Server

Home Page: http://colthreepv.github.io/angular-login-example

License: MIT License

JavaScript 91.21% CSS 8.79%

angular-login-example's People

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

angular-login-example's Issues

Your library and install seems totally out of sync. Pls see below

hi,
This sample code must have worked for you before but now is not working. I believe there is a mix up when you put it back into gibhub

within index.html

<script type="text/javascript" src="libs.js"></script>

<script type="text/javascript" src="app.js"></script>

<script type="text/javascript" src="templates-app.js"></script>

**** 2 libraries : lib.js and templates.app.js are missing based on index.html javascript preload.

instead in folders seeing : grandfather.js , routing-config.js , form-helper.js , error.js , login-service.js , morkhttp.js , pages.js , register.js

i matched up all the module names as per your injection to give that a spin

so I tried changing the index.html and preloading all of the above and also adding angular-ui-router ; it hangs at requiring 'templates-app' as one of the Inject dependency
in module : grandfather.js; do understand grandfather.js is required from decendency injection of other modules pointing to 'angular-login.grandfather'

When I take out the injection dependency 'templates-app' in the grandfather.js , then no more complaining of injection error.. but then get

Error: Unexpected request: GET home.tpl.html
and another error: TypeError: Cannot read property 'toString' of undefined

Your link to demo looks great, and I see the HTML code should render the same if the JS code don't break; but currently is way off . Please test and update with same working version as you have on that link. let me know thanks.

I really like to see this working.

Question: if I use route-segment library instead of ui-router, would it still work?

thanks

Token expiry

At the moment if a user logs in and a token has expired (simulated by deleting the token from tokenStorage), after refreshing the page the user will get a 401 error even if the state can be accessed by the public (e.g. home page). I think the state change should go through even if /users returns an error, as long as the state is available to public.

Rube Goldberg

Have you ever heard of the phrase "Rube Goldberg" job?

Demo doesn't work

I have npm, grunt, nodejs installed but when I run these commands:

$ git clone https://github.com/mrgamer/angular-login-example.git
$ cd angular-login-example
$ npm install && grunt && npm start

# Open browser on http://localhost:8080

The demo on http://localhost:8080 doesn't work. I tried it in Google Chrome on Ubuntu and Windows. Google Chrome console:

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8080/style.css
Uncaught ReferenceError: angular is not defined app.js:1
Uncaught ReferenceError: angular is not defined 

AngularJS isn't even included. Am I missing something here?

Service

Is there some idea for getting the users by a json file on a service and not locally?

Handle "401" errors in resolvePendingState

Maybe I don't use it correctly but my user api returns an 401 error when called by a not logged in user. In this case resolvePendingState is not returning to a correct state. I had to add this for my app to work well in any situation :

      function error(httpObj) {
       self.doneLoading = true;
        // duplicated logic from $stateChangeStart, slightly different, now we surely have the userRole informations.
        if (pendingState.to.accessLevel === undefined || pendingState.to.accessLevel === accessLevels.public ) {
          checkUser.resolve();
        } else {
          checkUser.reject('unauthorized');
        }
      },

File not Found

I don't know where the files are
style.css
libs.js
app.js
and templates-app.js

While i'm running in my broswer, i get an error.

minify issue

I've been using your code along with the generator-angular project, everything works great except when i build it in dist mode, it failed on the login-service, i suspect it is the injector issue, but i've tried everything, i couldn't get the dist code to work.

Logout

service url som logger ut användar och raderer authtoken från er auth-tabel.

(om man användar offentlig dator eller inte vil vära kvar inloggat)

Question regarding loginService.user object

I've got a service that needs to access the user object stored in login service. Is there a way to wait for the user object to become ready?

angular.module('apiService', [])
    .factory('apiService', function (loginService) {
        console.log(loginService.user);
   });

This returns {} in the console log. I think I can use localstorage, but I'm sure I'm missing something.

Thanks

All files included?

Are all the files included in the git downloads? I have tried downloading the zip and via git but there still seems to be files missing from the archive. Just as an example, templates-app.js is missing from the zip archive and I have a feeling there may be others missing.

Complete registration

Greetings, awesome library!

Now, i got a question regarding the complete registration process.

if (user.hasValidatedEmail) {
  wrappedService.userRole = userRoles.registered;
} else {
   wrappedService.userRole = userRoles.invalidEmail;
   $state.go('app.nagscreen');
}

Right now i'm not changing the state, as i use a lightbox to put the validation code. My problem is, after the validation code is sent, i need to update the user 'valid_email' to ', so i can now access the dashoboard, but i don't understand how could i do this... Any idea?

Loading state behavior

I cloned the repo, everything works fine except the "loading" view. In the demo it replaces whatever is currently active before switching to the desired state, whereas for me, the loading template simply appears below whatever view I currently have active before switching to the new state.

Multiple roles per user?

Hi,
thank you so much for your work - it works really well! In the project, where I want to use your solution, we need to assign multiple roles (more 'permissions') to one user. For example, there is superadmin that has all the permissions, but there can be users having (multiple, from one to all) permissions:

  • creating x
  • viewing y
  • administration of users
  • administration of x
  • administration of y

If got this right, in current solution, I would have to create role for each combination of those permissions?

Thanks in advance, hope you are still visiting this page ;-) Cheers, Szymon.

Can I store the userRole in the localStorage?

First, thank you for your example! I learned a lot from it :)

Now, I have a question, can I store the userRole in the localStorage?
In this example, when the user requested a $state, the loginService will do the getLoginData() function, if there is a token in the localStorage, the loginService will not init the userRole ,so the pendingStateChange will be inited. Which cause the the grandfather do the resolve to retrieve the userRole remotely.

So if I init the userRole to be public and store it in the localStorage, when user do some login action, I change the value of userRole in the localStorage. By this way, can I delete the resolve in the grandfather?Will it be unsafe if I delete the resolve?

Error while clicking twice a restricted link

Thanks for your example it really helped me figure how to secure some parts of my application. Plus it's a great intro to ui-router.
But there is a small bug I am unable to nail down: if you click twice the private link it never return to the $stateChangeSuccess.

Grunt

Well, I upgraded my Mac to Mavericks and GIT commands do not work; I am pretty pissed off about that one. Is there a way to install w/o Grunt?

privacy maybe?

Before showing email addresses in public like that after someone registers in the example, Can you at least set a small warning about that "Your emaill address and login credentials will be shared to the public" ?
If you can please remove our credentials from the homepage.
Thanks in advanced.

Access Loginservice within resolve

First off thanks for the proof of concept. I was trying to get the User Role within the resolve of my route. But is seems like it's not been set. Any suggestions?

angular.module('angular-login.pages', ['angular-login.grandfather'])
.config(function ($stateProvider) {
  $stateProvider
    .state('app.admin', {
      url: '/admin',
      templateUrl: 'pages/admin.tpl.html',
      accessLevel: accessLevels.admin
    })
    .state('app.user', {
      url: '/user',
      templateUrl: 'pages/user.tpl.html',
      accessLevel: accessLevels.user,
      resolve: {
        somedata: function (loginService, $q) {
          console.log(loginService.userRole); // is null
        }
      }
    });
});

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.