PageRenderTime 72ms CodeModel.GetById 61ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/grails-app/domain/corewars/User.groovy

https://code.google.com/p/corewars/
Groovy | 45 lines | 34 code | 11 blank | 0 comment | 1 complexity | ed42563d3cc124cd7c92aed06beca782 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception
 1package corewars
 2
 3class User {
 4
 5	transient springSecurityService
 6
 7	String username
 8	String password
 9	boolean enabled
10	boolean accountExpired
11	boolean accountLocked
12	boolean passwordExpired
13
14    String realName
15	String email
16
17    static hasMany = [openIds: OpenID]
18
19	static constraints = {
20		username blank: false, unique: true
21		password blank: false
22	}
23
24	static mapping = {
25		password column: '`password`'
26	}
27
28	Set<Role> getAuthorities() {
29		UserRole.findAllByUser(this).collect { it.role } as Set
30	}
31
32	def beforeInsert() {
33		encodePassword()
34	}
35
36	def beforeUpdate() {
37		if (isDirty('password')) {
38			encodePassword()
39		}
40	}
41
42	protected void encodePassword() {
43		password = springSecurityService.encodePassword(password)
44	}
45}