Permalink
Browse files

[grailstwitter] Formatting changes.

  • Loading branch information...
1 parent 3e54236 commit e813d7017bd8a1987e669f51f573ef6ac37b928b @pledbrook pledbrook committed Jun 19, 2012
View
18 grailstwitter/grails-app/conf/UrlMappings.groovy
@@ -1,13 +1,13 @@
class UrlMappings {
- static mappings = {
- "/$controller/$action?/$id?"{
- constraints {
- // apply constraints here
- }
- }
+ static mappings = {
+ "/$controller/$action?/$id?" {
+ constraints {
+ // apply constraints here
+ }
+ }
- "/"(controller: "status", action: "index")
- "500"(view:'/error')
- }
+ "/" controller: "status", action: "index"
+ "500" view: "/error"
+ }
}
View
252 grailstwitter/grails-app/controllers/org/grails/twitter/auth/LoginController.groovy
@@ -1,127 +1,127 @@
package org.grails.twitter.auth
-import grails.converters.JSON
-import grails.plugins.springsecurity.Secured
-
-import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils
-
-import org.springframework.security.authentication.AccountExpiredException
-import org.springframework.security.authentication.CredentialsExpiredException
-import org.springframework.security.authentication.DisabledException
-import org.springframework.security.authentication.LockedException
-import org.springframework.security.core.context.SecurityContextHolder as SCH
-import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
-import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter
-
-@Secured('IS_AUTHENTICATED_ANONYMOUSLY')
-class LoginController {
-
- /**
- * Dependency injection for the authenticationTrustResolver.
- */
- def authenticationTrustResolver
-
- /**
- * Dependency injection for the springSecurityService.
- */
- def springSecurityService
-
- /**
- * Default action; redirects to 'defaultTargetUrl' if logged in, /login/auth otherwise.
- */
- def index = {
- if (springSecurityService.isLoggedIn()) {
- redirect uri: SpringSecurityUtils.securityConfig.successHandler.defaultTargetUrl
- }
- else {
- redirect action: auth, params: params
- }
- }
-
- /**
- * Show the login page.
- */
- def auth = {
-
- def config = SpringSecurityUtils.securityConfig
-
- if (springSecurityService.isLoggedIn()) {
- redirect uri: config.successHandler.defaultTargetUrl
- return
- }
-
- String view = 'auth'
- String postUrl = "${request.contextPath}${config.apf.filterProcessesUrl}"
- render view: view, model: [postUrl: postUrl,
- rememberMeParameter: config.rememberMe.parameter]
- }
-
- /**
- * Show denied page.
- */
- def denied = {
- if (springSecurityService.isLoggedIn() &&
- authenticationTrustResolver.isRememberMe(SCH.context?.authentication)) {
- // have cookie but the page is guarded with IS_AUTHENTICATED_FULLY
- redirect action: full, params: params
- }
- }
-
- /**
- * Login page for users with a remember-me cookie but accessing a IS_AUTHENTICATED_FULLY page.
- */
- def full = {
- def config = SpringSecurityUtils.securityConfig
- render view: 'auth', params: params,
- model: [hasCookie: authenticationTrustResolver.isRememberMe(SCH.context?.authentication),
- postUrl: "${request.contextPath}${config.apf.filterProcessesUrl}"]
- }
-
- /**
- * Callback after a failed login. Redirects to the auth page with a warning message.
- */
- def authfail = {
-
- def username = session[UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_USERNAME_KEY]
- String msg = ''
- def exception = session[AbstractAuthenticationProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY]
- if (exception) {
- if (exception instanceof AccountExpiredException) {
- msg = SpringSecurityUtils.securityConfig.errors.login.expired
- }
- else if (exception instanceof CredentialsExpiredException) {
- msg = SpringSecurityUtils.securityConfig.errors.login.passwordExpired
- }
- else if (exception instanceof DisabledException) {
- msg = SpringSecurityUtils.securityConfig.errors.login.disabled
- }
- else if (exception instanceof LockedException) {
- msg = SpringSecurityUtils.securityConfig.errors.login.locked
- }
- else {
- msg = SpringSecurityUtils.securityConfig.errors.login.fail
- }
- }
-
- if (springSecurityService.isAjax(request)) {
- render([error: msg] as JSON)
- }
- else {
- flash.message = msg
- redirect action: auth, params: params
- }
- }
-
- /**
- * The Ajax success redirect url.
- */
- def ajaxSuccess = {
- render([success: true, username: springSecurityService.authentication.name] as JSON)
- }
-
- /**
- * The Ajax denied redirect url.
- */
- def ajaxDenied = {
- render([error: 'access denied'] as JSON)
- }
-}
+import grails.converters.JSON
+import grails.plugins.springsecurity.Secured
+
+import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils
+
+import org.springframework.security.authentication.AccountExpiredException
+import org.springframework.security.authentication.CredentialsExpiredException
+import org.springframework.security.authentication.DisabledException
+import org.springframework.security.authentication.LockedException
+import org.springframework.security.core.context.SecurityContextHolder as SCH
+import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
+import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter
+
+@Secured('IS_AUTHENTICATED_ANONYMOUSLY')
+class LoginController {
+
+ /**
+ * Dependency injection for the authenticationTrustResolver.
+ */
+ def authenticationTrustResolver
+
+ /**
+ * Dependency injection for the springSecurityService.
+ */
+ def springSecurityService
+
+ /**
+ * Default action; redirects to 'defaultTargetUrl' if logged in, /login/auth otherwise.
+ */
+ def index() {
+ if (springSecurityService.isLoggedIn()) {
+ redirect uri: SpringSecurityUtils.securityConfig.successHandler.defaultTargetUrl
+ }
+ else {
+ redirect action: "auth", params: params
+ }
+ }
+
+ /**
+ * Show the login page.
+ */
+ def auth() {
+
+ def config = SpringSecurityUtils.securityConfig
+
+ if (springSecurityService.isLoggedIn()) {
+ redirect uri: config.successHandler.defaultTargetUrl
+ return
+ }
+
+ String view = 'auth'
+ String postUrl = "${request.contextPath}${config.apf.filterProcessesUrl}"
+ render view: view, model: [postUrl: postUrl,
+ rememberMeParameter: config.rememberMe.parameter]
+ }
+
+ /**
+ * Show denied page.
+ */
+ def denied() {
+ if (springSecurityService.isLoggedIn() &&
+ authenticationTrustResolver.isRememberMe(SCH.context?.authentication)) {
+ // have cookie but the page is guarded with IS_AUTHENTICATED_FULLY
+ redirect action: full, params: params
+ }
+ }
+
+ /**
+ * Login page for users with a remember-me cookie but accessing a IS_AUTHENTICATED_FULLY page.
+ */
+ def full() {
+ def config = SpringSecurityUtils.securityConfig
+ render view: 'auth', params: params,
+ model: [hasCookie: authenticationTrustResolver.isRememberMe(SCH.context?.authentication),
+ postUrl: "${request.contextPath}${config.apf.filterProcessesUrl}"]
+ }
+
+ /**
+ * Callback after a failed login. Redirects to the auth page with a warning message.
+ */
+ def authfail() {
+
+ def username = session[UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_USERNAME_KEY]
+ String msg = ''
+ def exception = session[AbstractAuthenticationProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY]
+ if (exception) {
+ if (exception instanceof AccountExpiredException) {
+ msg = SpringSecurityUtils.securityConfig.errors.login.expired
+ }
+ else if (exception instanceof CredentialsExpiredException) {
+ msg = SpringSecurityUtils.securityConfig.errors.login.passwordExpired
+ }
+ else if (exception instanceof DisabledException) {
+ msg = SpringSecurityUtils.securityConfig.errors.login.disabled
+ }
+ else if (exception instanceof LockedException) {
+ msg = SpringSecurityUtils.securityConfig.errors.login.locked
+ }
+ else {
+ msg = SpringSecurityUtils.securityConfig.errors.login.fail
+ }
+ }
+
+ if (springSecurityService.isAjax(request)) {
+ render([error: msg] as JSON)
+ }
+ else {
+ flash.message = msg
+ redirect action: "auth", params: params
+ }
+ }
+
+ /**
+ * The Ajax success redirect url.
+ */
+ def ajaxSuccess() {
+ render([success: true, username: springSecurityService.authentication.name] as JSON)
+ }
+
+ /**
+ * The Ajax denied redirect url.
+ */
+ def ajaxDenied() {
+ render([error: 'access denied'] as JSON)
+ }
+}
View
30 grailstwitter/grails-app/controllers/org/grails/twitter/auth/LogoutController.groovy
@@ -1,16 +1,16 @@
package org.grails.twitter.auth
-import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils
-
-import grails.plugins.springsecurity.Secured
-
-@Secured('IS_AUTHENTICATED_ANONYMOUSLY')
-class LogoutController {
-
- /**
- * Index action. Redirects to the Spring security logout uri.
- */
- def index = {
- // TODO put any pre-logout code here
- redirect uri: SpringSecurityUtils.securityConfig.logout.filterProcessesUrl // '/j_spring_security_logout'
- }
-}
+import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils
+
+import grails.plugins.springsecurity.Secured
+
+@Secured('IS_AUTHENTICATED_ANONYMOUSLY')
+class LogoutController {
+
+ /**
+ * Index action. Redirects to the Spring security logout uri.
+ */
+ def index() {
+ // TODO put any pre-logout code here
+ redirect uri: SpringSecurityUtils.securityConfig.logout.filterProcessesUrl // '/j_spring_security_logout'
+ }
+}

0 comments on commit e813d70

Please sign in to comment.