Last change
on this file since 976 was
976,
checked in by robert@…, 10 years ago
|
Authentication and authorization for studies is added, according to ticket 118
|
File size:
1.2 KB
|
Line | |
---|
1 | /** |
---|
2 | * AuthenticationService |
---|
3 | * |
---|
4 | * Is used for keeping track of the logged in user |
---|
5 | * |
---|
6 | * @author robert@isdat.nl (Robert Horlings |
---|
7 | * @since 20101021 |
---|
8 | * @package dbnp.authentication |
---|
9 | * |
---|
10 | * Revision information: |
---|
11 | * $Rev$ |
---|
12 | * $Author$ |
---|
13 | * $Date$ |
---|
14 | */ |
---|
15 | package dbnp.authentication |
---|
16 | |
---|
17 | import org.codehaus.groovy.grails.plugins.springsecurity.GrailsUser |
---|
18 | |
---|
19 | class AuthenticationService { |
---|
20 | def SpringSecurityService |
---|
21 | |
---|
22 | boolean transactional = true |
---|
23 | |
---|
24 | protected boolean isLoggedIn() { |
---|
25 | def principal = SpringSecurityService.getPrincipal() |
---|
26 | |
---|
27 | // If the user is logged in, the principal should be a GrailsUser object. |
---|
28 | // If the user is not logged in, the principal is the 'anonymous username' |
---|
29 | // i.e. a string |
---|
30 | if( principal instanceof GrailsUser ) { |
---|
31 | return true; |
---|
32 | } |
---|
33 | |
---|
34 | return false; |
---|
35 | } |
---|
36 | |
---|
37 | protected SecUser getLoggedInUser() { |
---|
38 | def principal = SpringSecurityService.getPrincipal() |
---|
39 | |
---|
40 | // If the user is logged in, the principal should be a GrailsUser object. |
---|
41 | // If the user is not logged in, the principal is the 'anonymous username' |
---|
42 | // i.e. a string |
---|
43 | if( principal instanceof GrailsUser ) { |
---|
44 | return SecUser.findByUsername( principal.username ); |
---|
45 | } |
---|
46 | |
---|
47 | return null; |
---|
48 | } |
---|
49 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.