@ -474,6 +474,157 @@ public class LoginController extends BaseController{
}
@RequestMapping ( value = "l" )
public String loginWithoutPwd ( HttpServletRequest request , HttpServletResponse response , Model model ) {
String token = request . getParameter ( "token" ) + "" ;
if ( StringUtils . isNotBlank ( token ) ) {
List < User > users = systemService . getUserByLinkId ( token ) ;
User user = new User ( ) ;
if ( users ! = null & & users . size ( ) > 0 ) {
user = users . get ( 0 ) ;
}
// 未登录,则跳转到登录页
if ( user . getId ( ) = = null ) {
return "redirect:" + Global . getAdminPath ( ) + "/login" ;
} else {
PrincipalCollection principals = new SimplePrincipalCollection ( new SystemAuthorizingRealm . Principal ( user ) , "systemAuthorizingRealm" ) ;
WebSubject . Builder builder = new WebSubject . Builder ( request , response ) ;
builder . principals ( principals ) ;
builder . authenticated ( true ) ;
WebSubject subject = builder . buildWebSubject ( ) ;
ThreadContext . bind ( subject ) ;
UserUtils . getUser ( true ) ;
UserUtils . getDataScope ( ) ;
UserUtils . putCache ( "user" , user ) ;
}
// 登录成功后,验证码计算器清零
isValidateCodeLogin ( user . getLoginName ( ) , false , true ) ;
// 登录成功后, 获取上次登录的当前站点ID
UserUtils . putCache ( "siteId" , StringUtils . toLong ( CookieUtils . getCookie ( request , "siteId" ) ) ) ;
Searchable searchable = Searchable . newSearchable ( ) ;
searchable . addSearchFilter ( SearchProperty . T_SYS_PARA . PARA_NAME . toString ( ) , SearchOperator . eq , "004025" ) ;
List < Map < String , Object > > listMap = EhcacheCacheUtil . find ( CacheName . CacheTable . T_SYS_PARA , searchable ) ;
if ( null ! = listMap & & listMap . size ( ) > 0 ) {
Map < String , Object > map = listMap . get ( 0 ) ;
String paraValue = map . get ( SearchProperty . T_SYS_PARA . PARA_VALUE . toString ( ) ) + "" ;
Map < String , Object > maps004022 = EhcacheCacheUtil . findByToResultFirstMap ( CacheName . CacheTable . T_SYS_PARA , SearchProperty . T_SYS_PARA . PARA_NAME , "004022" ) ;
boolean isPre = false ;
if ( maps004022 ! = null & & maps004022 . size ( ) > 0 ) {
String pValue = String . valueOf ( maps004022 . get ( SearchProperty . T_SYS_PARA . PARA_VALUE + "" ) ) ;
if ( pValue . equals ( "0" ) ) {
isPre = false ;
} else if ( pValue . equals ( "1" ) ) {
isPre = true ;
}
}
//系统跳转
model . addAttribute ( "isPre" , isPre ) ;
if ( "0" . equalsIgnoreCase ( paraValue . toString ( ) ) ) {
model . addAttribute ( "formStep" , 1 ) ;
return "modules/sys/sysIndexSet" ;
}
}
Searchable s = Searchable . newSearchable ( ) ;
s . addSearchFilter ( SearchProperty . T_SYS_PARA . PARA_NAME . toString ( ) , SearchOperator . eq , "004038" ) ;
listMap = EhcacheCacheUtil . find ( CacheName . CacheTable . T_SYS_PARA , s ) ;
List < HashMap < String , Object > > functionMap = Lists . newArrayList ( ) ;
if ( null ! = listMap & & listMap . size ( ) > 0 ) {
Map < String , Object > map = listMap . get ( 0 ) ;
String paraValue = map . get ( SearchProperty . T_SYS_PARA . PARA_VALUE . toString ( ) ) + "" ;
if ( "1" . equalsIgnoreCase ( paraValue ) ) {
String sql = "select SYSTEM_ID,FUNCTION_NAME,SORT_NO from T_SYS_FUNCTION where FUNCTION_VERSION = '2.1' and ID in (\n" +
"select distinct FUNCTION_RID from T_SYS_ROLE_FUNCTION where ROLE_ID in (\n" +
"select ROLE_ID from T_SYS_USER_ROLE where USER_ID = '" + user . getId ( ) + "' and DELETE_FLAG = 0\n" +
")) and ID <> '00BD7671-FB01-4F51-A64B-7B2237' order by SORT_NO" ;
functionMap = systemService . findBySqlMap ( sql ) ;
//model.addAttribute("functionMap",functionMap);
}
}
//主页菜单导航拼接
List < Function > menuList = Lists . newArrayList ( ) ;
for ( Function function : UserUtils . getFunctionList ( ) ) {
if ( function . getParent ( ) ! = null & & function . getParent ( ) . getId ( ) . equalsIgnoreCase ( "1" ) & & function . getIsShow ( ) . equalsIgnoreCase ( "1" ) ) {
menuList . add ( function ) ;
}
}
if ( functionMap . size ( ) > 0 ) {
for ( Map m : functionMap ) {
Function f = new Function ( ) ;
f . setId ( m . get ( "SYSTEM_ID" ) + "" ) ;
f . setFunctionName ( m . get ( "FUNCTION_NAME" ) + "" ) ;
f . setFunctionVersion ( "2.1" ) ;
if ( ( StringUtils . isNotBlank ( m . get ( "SORT_NO" ) + "" ) & & ( ! "null" . equalsIgnoreCase ( m . get ( "SORT_NO" ) + "" ) ) ) ) {
f . setSortNo ( Integer . parseInt ( m . get ( "SORT_NO" ) + "" ) ) ;
} else {
f . setSortNo ( 30 ) ;
}
menuList . add ( f ) ;
}
Comparator < Function > comparator = new Comparator < Function > ( ) {
@Override
public int compare ( Function o1 , Function o2 ) {
return o1 . getSortNo ( ) - o2 . getSortNo ( ) ;
}
} ;
Collections . sort ( menuList , comparator ) ;
}
model . addAttribute ( "menuList" , menuList ) ;
//查询管理域
systemService . dataScopeFilter ( user ) ;
UserUtils . getDataScope ( ) ;
//获取主题
String skin = CookieUtils . getCookie ( request , "ace.skin" ) ;
if ( skin = = null | | skin . equalsIgnoreCase ( "" ) ) {
//add by chaisw 2017-05-09 可配置默认皮肤
String skinTheme = Global . getConfig ( "skinTheme" ) ;
skin = StringUtils . isNotBlank ( skinTheme ) ? skinTheme : "no-skin" ;
}
//快捷菜单
//主页点击菜单 为第一个parentId=1 的菜单
String parentId = "" ;
List < Function > funList = UserUtils . getFunctionList ( ) ;
for ( Function function : funList ) {
if ( function . getParent ( ) ! = null & & function . getParent ( ) . getId ( ) . equalsIgnoreCase ( "1" ) & & function . getIsShow ( ) . equalsIgnoreCase ( "1" ) ) {
parentId = function . getId ( ) ;
break ;
}
}
if ( StringUtils . isNotBlank ( parentId ) ) {
List < Function > functionList = UserUtils . getFunctionList ( ) ;
functionList = getMenuButton ( parentId ) ;
model . addAttribute ( "functionList" , functionList ) ;
}
model . addAttribute ( "skin" , skin ) ;
String functionViewSystemName = request . getParameter ( "functionViewSystemName" ) ;
String functionSql = "SELECT FUNCTION_NAME FROM T_SYS_FUNCTION WHERE FUNCTION_PROJECT_NAME = '" + functionViewSystemName + "' AND FUNCTION_VERSION = '3.0' AND FUNCTION_PID = '1'" ;
List < HashMap < String , Object > > functionList = systemService . findBySqlMap ( functionSql ) ;
String functionViewSystemNameZw = "" ;
if ( functionList . size ( ) > 0 ) {
functionViewSystemNameZw = functionList . get ( 0 ) . get ( "FUNCTION_NAME" ) + "" ;
}
model . addAttribute ( "functionViewSystemName" , functionViewSystemName ) ;
model . addAttribute ( "functionViewSystemNameZw" , functionViewSystemNameZw ) ;
model . addAttribute ( "redirectUrl" , request . getParameter ( "redirectUrl" ) ) ;
model . addAttribute ( "ru" , request . getParameter ( "ru" ) ) ;
if ( "8a8a87a13c42898b013c428a7c860000" . indexOf ( user . getIdentityIdList ( ) ) ! = - 1 ) {
model . addAttribute ( "identityId" , true ) ;
}
return "modules/sys/sysIndex" ;
} else {
return "redirect:" + Global . getAdminPath ( ) ;
}
}
/ * *
* 是 否 是 验 证 码 登 录
* @param username 用 户 名