Commit 033c551e authored by njrfhtd's avatar njrfhtd
Browse files

some fixings CDEK-1722

1) Нет сообщения об отсутствии привязки сотрудника к пользователю.
parent bc6f9947
Showing with 26 additions and 2 deletions
+26 -2
package ru.cdek.web.mvc;
import com.cdek.catalog.common.entity.Employee;
import com.cdek.commons.js.JSUser;
import com.cdek.transport.ek4.user.FrontUser;
import com.cdek.warehouse.client.WarehouseClient;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
......@@ -29,6 +35,10 @@ public class BaseMVCController {
@Autowired
protected FrontMessageService frontMessageService;
@Autowired
@Qualifier("warehouseClient")
protected WarehouseClient warehouseClient;
@ModelAttribute("lang3")
public String getIso3Lang() {
return UserAuthUtils.getLocale3sign();
......@@ -39,6 +49,21 @@ public class BaseMVCController {
return LocaleContextHolder.getLocale().getLanguage();
}
@ModelAttribute("noEmployee")
public String getNoEmployee() {
JSUser jsUser = UserAuthUtils.getCurrentUser();
if(null == jsUser.token) {
return "";
}
Employee employee = warehouseClient.findEmployeeByUserCode(jsUser.getCode(), jsUser.getLang());
if (null == employee) {
return frontMessageService.getMsg("error.user.without.employee");
}
return "";
}
public void setContext(ApplicationContext context) {
this.context = context;
}
......
......@@ -85,6 +85,7 @@
<@security.authorize access="isAuthenticated()">
<p class="navbar-text">
<@security.authentication property="principal.login"> </@security.authentication>
- <span class="" style="color: red;">${noEmployee}</span>
</p>
</@security.authorize>
<li class="divider-vertical"></li>
......
......@@ -26,8 +26,6 @@ import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import com.cdek.transport.auth.Roles;
/**
* Аутентификация пользователя при помощи UserApi
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment