source: trunk/grails-app/domain/dbnp/authentication/SecUser.groovy @ 1939

Last change on this file since 1939 was 1939, checked in by robert@…, 7 years ago

Updated module notification so that it also sends authentication to modules.

  • Property svn:keywords set to Rev Author Date
File size: 1.2 KB
Line 
1package dbnp.authentication
2
3class SecUser implements Serializable {
4
5        String username
6        String password
7        String email
8        Date dateCreated
9        boolean enabled
10        boolean accountExpired
11        boolean accountLocked
12        boolean passwordExpired
13        boolean userConfirmed   // True if the user has confirmed his subscription using the link in the email
14        boolean adminConfirmed  // True if the administrator has confirmed this subscription using the link in the email
15
16        static constraints = {
17                username blank: false, unique: true
18                password blank: false
19                email blank: false
20        }
21
22        static mapping = {
23                password column: '`password`'
24                enabled formula: 'USER_CONFIRMED AND ADMIN_CONFIRMED'
25        }
26
27        Set<SecRole> getAuthorities() {
28                SecUserSecRole.findAllBySecUser(this).collect { it.secRole } as Set
29        }
30
31        public boolean equals(Object y) {
32                if (!(y instanceof SecUser)) {
33                        return false;
34                }
35
36                if (y == null) return false;
37
38                return this.id == y.id
39        }
40
41        public boolean hasAdminRights() {
42                return getAuthorities().contains(SecRole.findByAuthority('ROLE_ADMIN'));
43        }
44       
45        /**
46         * Delete all remote logins for this user as well.
47         */
48        def beforeDelete = {
49                executeUpdate( "DELETE FROM SessionAuthenticatedUser sau WHERE sau.secUser = :secUser", [ "secUser": this ] );
50        }
51}
Note: See TracBrowser for help on using the repository browser.