I have user roles: user , manager , admin . I need to authenticate them in controllers (methods). For example, only admin can delete (now it looks like this, you need to change that only the administrator must have permission):
def deleteBook(id: Int) = DBAction { findById(id) match { case Some(entity) => { books.filter(_.id === id).delete Ok("") } case None => Ok("") } }
I have many controllers and methods. I need to authenticate before requesting a process (e.g. deleting a workbook). My routes file contains:
... DELETE /books/:id @controllers.Book.deleteBook(id: Int) ...
Some routes are available only for the administrator and manager. Some of them are intended for all types of users.
I am currently seeing the deadbolt2scala authorization module.
Can you recommend the best way to authenticate multi-user in playframework scala?
source share