I have a Single Page Application in AngularJS with API in Ruby on Rails (Grape framework). My authentication system looks like this:
- User create an account. Sends information to server.
- Server save user in database and generate token with Devise. Token and user information is send to Angular.
- Angular save token and user info in storage (angular-storage) and token is added to every request (Authorization header).
- When user click log out button, storage is cleared and token is deleted in database.
My question is: it this secure, or do I need to use something like JWT? Can I send a role name (for example 'moderator') to Angular without any encoding this? (of course server will always check, if this user with this token can do something) I also will implement doorkeeper to my app in near future.