Author | Message |
---|---|
talisunep
Posts: 140
|
Posted 21:24 May 28, 2013 |
Professor in the case we want spring security to authenticate using the user email and password instead of its default username and password and check how can we implement this? |
cysun
Posts: 2935
|
Posted 21:50 May 28, 2013 |
Spring Security's default schema for authentication uses a users table and an authorities table, but it's OK if your schema is different - in this case you'd have an email column instead of a username column. You just need to specify the users-by-username-query attribute and/or the authorities-by-username-query attribute of <jdbc-user-service>. See http://static.springsource.org/spring-security/site/docs/3.1.x/reference/springsecurity-single.html#nsa-jdbc-user-service |
talisunep
Posts: 140
|
Posted 23:12 May 29, 2013 |
professor for hw6 i was wondering do we need to be able to register administrators too? |
cysun
Posts: 2935
|
Posted 08:38 May 30, 2013 |
|
talisunep
Posts: 140
|
Posted 18:21 May 30, 2013 |
im trying to get current user id to pass it to add review table in my addReview controller User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); but when i run program my controller for addReview (METHOD POST) throws an error saying that i cant invoke a User object under this controller as my @Model Attribute is Review review so what im trying now is using Authentication auth = SecurityContextHolder.getContext().getAuthentication(); i also tried using is there any way to write a query from the controller to to get the current logged in user ID? i dont know if i am trying the right approach?
Last edited by talisunep at
18:22 May 30, 2013.
|
cysun
Posts: 2935
|
Posted 20:14 May 30, 2013 |
There's nothing wrong with using DAO to get a User object using username. The error you got must be because of something else. |
talisunep
Posts: 140
|
Posted 20:30 May 30, 2013 |
im trying to user userDao now User user = userDao.getId(uname); getting error org.hibernate.exception.SQLGrammarException: could not extract ResultSet my dao implementation is @Override } |
talisunep
Posts: 140
|
Posted 21:51 May 30, 2013 |
sorry my query was not correct ..its working now with User user = entityManager.createQuery("from User where userName= :uname", User.class).setParameter("uname", uname).getSingleResult(); |