- Timestamp:
- Mar 10, 2011, 11:02:53 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/authentication/LoginController.groovy
r1588 r1614 57 57 String postUrl = "${request.contextPath}${config.apf.filterProcessesUrl}" 58 58 render view: view, model: [postUrl: postUrl, 59 59 rememberMeParameter: config.rememberMe.parameter] 60 60 } 61 61 62 63 64 65 66 def consumer= params.consumer67 def token= params.token62 /** 63 * Shows the login page for users from a module 64 */ 65 def auth_remote = { 66 def consumer = params.consumer 67 def token = params.token 68 68 69 if( consumer == null || token == null ) { 70 throw new Exception( "Consumer and Token must be given!" ); 69 if (consumer == null || token == null) { 70 throw new Exception("Consumer and Token must be given!"); 71 } 72 73 def returnUrl = params.returnUrl 74 75 // If the user is already authenticated with this session_id, redirect 76 // him 77 if (authenticationService.isRemotelyLoggedIn(consumer, token)) { 78 if (returnUrl) { 79 redirect url: returnUrl 80 } else { 81 redirect controller: 'home' 71 82 } 83 } 72 84 73 def returnUrl = params.returnUrl 85 // If the user is already logged in locally, we log him in and 86 // immediately redirect him 87 if (authenticationService.isLoggedIn()) { 88 authenticationService.logInRemotely(consumer, token, authenticationService.getLoggedInUser()) 74 89 75 // If the user is already authenticated with this session_id, redirect 76 // him 77 if( authenticationService.isRemotelyLoggedIn( consumer, token ) ) { 78 if( returnUrl ) { 79 redirect url: returnUrl 80 } else { 81 redirect controller: 'home' 82 } 83 } 90 if (returnUrl) { 91 redirect url: returnUrl 92 } else { 93 redirect controller: 'home' 94 } 95 } 84 96 85 // If the user is already logged in locally, we log him in and 86 // immediately redirect him 87 if (authenticationService.isLoggedIn()) { 88 authenticationService.logInRemotely( consumer, token, authenticationService.getLoggedInUser() ) 97 // Otherwise we show the login screen 98 def config = SpringSecurityUtils.securityConfig 99 String view = 'auth' 100 String postUrl = "${request.contextPath}${config.apf.filterProcessesUrl}" 101 String redirectUrl = g.createLink(controller: 'login', action: 'auth_remote', params: [consumer: params.consumer, token: params.token, returnUrl: params.returnUrl], absolute: true) 102 render view: view, model: [postUrl: postUrl, 103 rememberMeParameter: config.rememberMe.parameter, redirectUrl: redirectUrl] 104 } 89 105 90 if( returnUrl ) {91 redirect url: returnUrl92 } else {93 redirect controller: 'home'94 }95 }96 97 // Otherwise we show the login screen98 def config = SpringSecurityUtils.securityConfig99 String view = 'auth'100 String postUrl = "${request.contextPath}${config.apf.filterProcessesUrl}"101 String redirectUrl = g.createLink( controller: 'login', action: 'auth_remote', params: [ consumer: params.consumer, token: params.token, returnUrl: params.returnUrl ], absolute: true )102 render view: view, model: [postUrl: postUrl,103 rememberMeParameter: config.rememberMe.parameter, redirectUrl: redirectUrl ]104 }105 106 106 /** 107 107 * Show denied page. … … 109 109 def denied = { 110 110 if (springSecurityService.isLoggedIn() && 111 111 authenticationTrustResolver.isRememberMe(SCH.context?.authentication)) { 112 112 // have cookie but the page is guarded with IS_AUTHENTICATED_FULLY 113 113 redirect action: full, params: params … … 122 122 render view: 'auth', params: params, 123 123 model: [hasCookie: authenticationTrustResolver.isRememberMe(SCH.context?.authentication), 124 124 postUrl: "${request.contextPath}${config.apf.filterProcessesUrl}"] 125 125 } 126 126
Note: See TracChangeset
for help on using the changeset viewer.