package com.axelor.auth;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;

import com.axelor.auth.db.User;

public class AuthUtils {
	
	public static Subject getSubject() {
		return SecurityUtils.getSubject();
	}

	public static User getUser() {
		Subject subject = getSubject();
		if (subject == null || subject.getPrincipal() == null)
			return null;
		return User.all().filter("self.code = ?", subject.getPrincipal()).fetchOne();
	}
}

@@ -58,16 +58,77 @@
 yUtils;%0A
+import org.apache.shiro.UnavailableSecurityManagerException;%0A
 import o
@@ -160,16 +160,16 @@
 ubject;%0A
-
 %0Aimport 
@@ -259,16 +259,25 @@
 ect() %7B%0A
+%09%09try %7B%0A%09
 %09%09return
@@ -305,16 +305,86 @@
 ject();%0A
+%09%09%7D catch (UnavailableSecurityManagerException e)%7B%0A%09%09%7D%0A%09%09return null;%0A
 %09%7D%0A%0A%09pub

Handle unavailable security manager error.