source: trunk/grails-app/controllers/AppCoreController.groovy @ 134

Last change on this file since 134 was 134, checked in by gav, 15 years ago

Add icons from famfamfam silk icons, add acknowledgement page to suite.
Adjust AssignedPerson? controller so that a task.id is required to create.
Move Add AssignedPerson? link up to TaskDetailed? show page.
Further improvements to taskDetailed show tabs.
Adjust TaskProcedureDetailed? controller to allow linking a Procedure to a task during creation.
Adjust TaskRecurringSchedule? to a one-to-one cascading relationship.
Modify CSS class duration to time and added icons.
Regenerate some pages.

File size: 3.4 KB
Line 
1import org.codehaus.groovy.grails.plugins.springsecurity.Secured
2
3class AppCoreController extends BaseController {
4
5    def authenticateService
6
7    def index = { redirect(action:home,params:params) }
8
9    // the delete, save and update actions only accept POST requests
10    //def allowedMethods = [delete:'POST', save:'POST', update:'POST']
11
12    def welcome = {
13        def personInstance = Person.get(authenticateService.userDomain().id)
14        flash.message = "Welcome, ${personInstance.firstName} ${personInstance.lastName}."
15
16        def sess = getSession()
17        sess.setMaxInactiveInterval(personInstance.sessionTimeout)
18        redirect(action:home)
19    }
20
21    def home = {
22    }
23
24    def options = {
25    }
26
27    def acknowledgements = {
28    }
29
30    def changeSessionTimeout = {
31        if (request.method == 'GET') {
32            def personInstance = Person.get(authenticateService.userDomain().id)
33            return [ personInstance : personInstance ]       
34        }
35        if (request.method == 'POST') {
36            def personInstance = Person.get(authenticateService.userDomain().id)
37//             personInstance.sessionTimeout = params.sessionTimeout.toInteger()
38                personInstance.properties = params
39                if (!personInstance.hasErrors() && personInstance.save()) {
40                    def sess = getSession()
41                    sess.setMaxInactiveInterval(personInstance.sessionTimeout)
42                    flash.message = "Session timeout changed."
43                    redirect(action:options)
44                }
45                else {
46                    render(view:'changeSessionTimeout',model:[personInstance:personInstance])
47                }
48        }
49    }         
50
51    def changePassword = {
52        //def principal = authenticateService.principal()
53        //println principal.getAuthorities()
54
55        if (request.method == 'GET') {
56            def personInstance = Person.get(authenticateService.userDomain().id)
57            return [ personInstance : personInstance ]       
58        } 
59
60        if (request.method == 'POST') {
61            def personInstance = Person.get(authenticateService.userDomain().id)
62
63            if(params.confirmPass == params.pass) {
64                personInstance.pass = params.pass
65                personInstance.password = authenticateService.encodePassword(personInstance.pass)
66
67                if (!personInstance.hasErrors() && personInstance.save()) {
68                    //userCache.removeUserFromCache(personInstance.loginName)
69                    flash.message = "Password changed successfully."
70                    redirect(action:options)
71                }
72                else {
73                    render(view:'changePassword',model:[personInstance:personInstance])
74                }
75            }
76            else {
77                personInstance.errors.reject('person.pass.doesNotMatch',            // Error code, see grails-app/i18n/message.properties
78                                                                ['pass', 'class Person'].toArray(),      // Groovy ListArray cast to Object[]
79                                                                 '[NothingUseMessageProperites]')  // Default mapping string.
80                render(view:'changePassword',model:[personInstance:personInstance])
81            }
82               
83        } 
84    }
85
86    @Secured(['ROLE_Manager'])   
87    def manager = {
88    }
89
90    @Secured(['ROLE_AppAdmin'])   
91    def appAdmin = {
92    }
93
94}
Note: See TracBrowser for help on using the repository browser.