commit 275f21aa50d5216f1961e9bedadd43ed11c1730a Author: pioneer Date: Thu Nov 24 10:56:18 2022 +0800 open diff --git a/README.md b/README.md new file mode 100644 index 0000000..a274d50 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# open-JSD-10126 + +JSD-10126 FR调用OA的单点认证接口,完成认证登录\ +免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ +仅作为开发者学习参考使用!禁止用于任何商业用途!\ +为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系【pioneer】处理。 \ No newline at end of file diff --git a/lib/finekit-10.0-20220427.jar b/lib/finekit-10.0-20220427.jar new file mode 100644 index 0000000..6793f18 Binary files /dev/null and b/lib/finekit-10.0-20220427.jar differ diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..0905197 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,24 @@ + + + com.eco.plugin.xx.mbe + + yes + 1.0.3 + 10.0 + 2021-02-10 + fr.open + com.fr.plugin + + + + 2022-5-12 10:46:33 + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/FunctionRecoder.java b/src/main/java/com/fr/plugin/FunctionRecoder.java new file mode 100644 index 0000000..963ca84 --- /dev/null +++ b/src/main/java/com/fr/plugin/FunctionRecoder.java @@ -0,0 +1,12 @@ +package com.fr.plugin; + +import com.fr.plugin.transform.ExecuteFunctionRecord; +import com.fr.plugin.transform.FunctionRecorder; + +@FunctionRecorder +public class FunctionRecoder { + @ExecuteFunctionRecord + public void exe(){ + System.out.println("插件功能埋点,虽然不会执行,除非上架应用"); + } +} diff --git a/src/main/java/com/fr/plugin/MBEConfig.java b/src/main/java/com/fr/plugin/MBEConfig.java new file mode 100644 index 0000000..abe159a --- /dev/null +++ b/src/main/java/com/fr/plugin/MBEConfig.java @@ -0,0 +1,42 @@ +package com.fr.plugin; + +import com.fr.config.*; +import com.fr.config.holder.Conf; +import com.fr.config.holder.factory.Holders; + +@Visualization(category = "xxOA插件配置") +public class MBEConfig extends DefaultConfiguration { + + private static volatile MBEConfig config = null; + + public static MBEConfig getInstance() { + if (config == null) { + config = ConfigContext.getConfigInstance(MBEConfig.class); + } + return config; + } + @Identifier(value = "apiUrl", name = "用户校验身份接口", description = "用户校验身份接口", status = Status.SHOW) + private Conf apiUrl = Holders.simple("http://xxxxxxxx/api/mubea/check/checkuser"); + @Identifier(value = "ukey", name = "ukey", description = "描述", status = Status.SHOW) + private Conf ukey = Holders.simple(""); + public String getApiUrl() { + return apiUrl.get(); + } + public void setApiUrl(String apiUrl) { + this.apiUrl.set(apiUrl); + } + public String getUkey() { + return ukey.get(); + } + public void setUkey(String ukey) { + this.ukey.set(ukey); + } + @Override + public Object clone() throws CloneNotSupportedException { + MBEConfig cloned = (MBEConfig) super.clone(); + cloned.apiUrl = (Conf) this.apiUrl.clone(); + cloned.ukey = (Conf) this.ukey.clone(); + return cloned; + } + +} \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/MBELifeCycleMonitor.java b/src/main/java/com/fr/plugin/MBELifeCycleMonitor.java new file mode 100644 index 0000000..ba99cb0 --- /dev/null +++ b/src/main/java/com/fr/plugin/MBELifeCycleMonitor.java @@ -0,0 +1,18 @@ +package com.fr.plugin; + +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor; +import com.fr.stable.fun.Authorize; + +@Authorize +public class MBELifeCycleMonitor extends AbstractPluginLifecycleMonitor { + @Override + public void afterRun(PluginContext pluginContext) { + MBEConfig.getInstance(); + } + + @Override + public void beforeStop(PluginContext pluginContext) { + + } +} diff --git a/src/main/java/com/fr/plugin/http/MBEHttpHandler.java b/src/main/java/com/fr/plugin/http/MBEHttpHandler.java new file mode 100644 index 0000000..7302798 --- /dev/null +++ b/src/main/java/com/fr/plugin/http/MBEHttpHandler.java @@ -0,0 +1,16 @@ +package com.fr.plugin.http; + +import com.fr.decision.fun.HttpHandler; +import com.fr.decision.fun.impl.AbstractHttpHandlerProvider; +import com.fr.plugin.http.handler.*; + +public class MBEHttpHandler extends AbstractHttpHandlerProvider { + HttpHandler[] actions = new HttpHandler[]{ + new ALLMbeLogin1Handler(), + }; + + @Override + public HttpHandler[] registerHandlers() { + return actions; + } +} diff --git a/src/main/java/com/fr/plugin/http/MBEUrlAliasProvider.java b/src/main/java/com/fr/plugin/http/MBEUrlAliasProvider.java new file mode 100644 index 0000000..a2b3946 --- /dev/null +++ b/src/main/java/com/fr/plugin/http/MBEUrlAliasProvider.java @@ -0,0 +1,14 @@ +package com.fr.plugin.http; + +import com.fr.decision.fun.impl.AbstractURLAliasProvider; +import com.fr.decision.webservice.url.alias.URLAlias; +import com.fr.decision.webservice.url.alias.URLAliasFactory; + +public class MBEUrlAliasProvider extends AbstractURLAliasProvider { + @Override + public URLAlias[] registerAlias() { + return new URLAlias[]{ + URLAliasFactory.createPluginAlias("/mbeLogin", "/mbeLogin", true), + }; + } +} diff --git a/src/main/java/com/fr/plugin/http/handler/ALLMbeLogin1Handler.java b/src/main/java/com/fr/plugin/http/handler/ALLMbeLogin1Handler.java new file mode 100644 index 0000000..f491f50 --- /dev/null +++ b/src/main/java/com/fr/plugin/http/handler/ALLMbeLogin1Handler.java @@ -0,0 +1,286 @@ +package com.fr.plugin.http.handler; + +import com.fanruan.api.log.LogKit; +import com.fanruan.api.net.http.HttpKit; +import com.fr.base.ServerConfig; +import com.fr.base.TemplateUtils; +import com.fr.config.EmailServerConfig; +import com.fr.data.NetworkHelper; +import com.fr.decision.authority.data.User; +import com.fr.decision.config.FSConfig; +import com.fr.decision.config.LoginVerificationConfig; +import com.fr.decision.config.mobile.MobileConfig; +import com.fr.decision.fun.impl.BaseHttpHandler; +import com.fr.decision.mobile.terminal.TerminalHandler; +import com.fr.decision.privilege.TransmissionTool; +import com.fr.decision.webservice.bean.authentication.LoginClientBean; +import com.fr.decision.webservice.bean.authentication.LoginRequestInfoBean; +import com.fr.decision.webservice.bean.authentication.LoginResponseInfoBean; +import com.fr.decision.webservice.bean.authentication.OriginUrlResponseBean; +import com.fr.decision.webservice.exception.captcha.UnverifiedCaptchaException; +import com.fr.decision.webservice.exception.general.SpecialCharProhibitException; +import com.fr.decision.webservice.exception.login.LoginInfoSignErrorException; +import com.fr.decision.webservice.exception.login.UserLoginException; +import com.fr.decision.webservice.utils.ControllerFactory; +import com.fr.decision.webservice.utils.DecisionStatusService; +import com.fr.decision.webservice.utils.WebServiceUtils; +import com.fr.decision.webservice.utils.controller.AuthenticController; +import com.fr.decision.webservice.v10.login.slider.SliderVerificationService; +import com.fr.decision.webservice.v10.password.strategy.PasswordStrategyService; +import com.fr.decision.webservice.v10.register.RegisterService; +import com.fr.decision.webservice.v10.sms.SMSService; +import com.fr.decision.webservice.v10.user.UserService; +import com.fr.json.JSONObject; +import com.fr.log.FineLoggerFactory; +import com.fr.plugin.MBEConfig; +import com.fr.security.JwtUtils; +import com.fr.stable.CodeUtils; +import com.fr.stable.StringUtils; +import com.fr.stable.web.Device; +import com.fr.store.Converter; +import com.fr.third.fasterxml.jackson.core.JsonGenerationException; +import com.fr.third.fasterxml.jackson.core.JsonParseException; +import com.fr.third.fasterxml.jackson.databind.JsonMappingException; +import com.fr.third.fasterxml.jackson.databind.ObjectMapper; +import com.fr.third.fasterxml.jackson.databind.type.TypeFactory; +import com.fr.third.springframework.web.bind.annotation.RequestMethod; +import com.fr.web.utils.WebUtils; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; +import java.util.HashMap; +import java.util.Map; + + +public class ALLMbeLogin1Handler extends BaseHttpHandler { + @Override + public RequestMethod getMethod() { + return null; + } + + @Override + public String getPath() { + return "/mbeLogin"; + } + + @Override + public boolean isPublic() { + return true; + } + + private static final ObjectMapper objectMapper = new ObjectMapper(); + + @Override + public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception { + String requestBody = getRequestBody(req); + try { + LoginRequestInfoBean infoBean = deserialize(requestBody, LoginRequestInfoBean.class); + //账号密码验证 + if (!checkPasswordAndUserName(infoBean)) { + throw new UserLoginException(); + } + LoginResponseInfoBean responseInfoBean = doLogin(req, res, infoBean); + RespJsonObj respJsonObj = new RespJsonObj(); + respJsonObj.setData(responseInfoBean); + res.setContentType("application/json;charset=UTF-8"); + WebUtils.printAsString(res, serialize(respJsonObj)); + }catch (Exception e){ + LogKit.error("login error",e); + WebUtils.printAsString(res, serialize(e)); + } + } + class RespJsonObj{ + LoginResponseInfoBean data; + + public LoginResponseInfoBean getData() { + return data; + } + + public void setData(LoginResponseInfoBean data) { + this.data = data; + } + } + + private long getTokenTimeOutByValidity(int req) { + return req == -2 ? 1209600000L : FSConfig.getInstance().getLoginConfig().getLoginTimeout(); + } + + private String generateToken(User req, long var2) { + return this.generateToken(req.getUserName(), req.getDisplayName(), req.getTenantId(), var2); + } + + private boolean needLoginVerification(Device req) { + if (req.isMobile()) { + return LoginVerificationConfig.getInstance().isSmsVerification() && SMSService.getInstance().isSMSAvailable(); + } else { + return LoginVerificationConfig.getInstance().isSmsVerification() && SMSService.getInstance().isSMSAvailable() || LoginVerificationConfig.getInstance().isEmailVerification() && EmailServerConfig.getInstance().isEmailConfigValid(); + } + } + + private void loginInfoSignVerify(Device req, LoginRequestInfoBean var2) throws Exception { + if (!req.isPC() && MobileConfig.getInstance().getLoginIntegrityCheckConfig().isCheckEnabled()) { + StringBuilder var3 = new StringBuilder(); + var3.append("username=").append(var2.getUsername()).append("&password=").append(var2.getPassword()).append("&macAddress=").append(StringUtils.isEmpty(var2.getMacAddress()) ? "" : var2.getMacAddress()).append("&deviceName=").append(StringUtils.isEmpty(var2.getDeviceName()) ? "" : var2.getDeviceName()); + if (!StringUtils.equals(var3.toString(), TransmissionTool.decrypt(var2.getSign()))) { + throw new LoginInfoSignErrorException(); + } + } + } + + private LoginResponseInfoBean doLogin(HttpServletRequest req, HttpServletResponse res, LoginRequestInfoBean var3) throws Exception { + Device device = NetworkHelper.getDevice(req); + this.loginInfoSignVerify(device, var3); + String var5 = TransmissionTool.decrypt(var3.isEncrypted(), var3.isSupportCustomEncrypt(), var3.getPassword()); + String var6 = var3.getUsername(); + if (WebServiceUtils.containSQLChars(var6)) { + throw new SpecialCharProhibitException(); + } else { + String var7 = WebServiceUtils.getIpInfoFromRequest(req); + SliderVerificationService.getInstance().dealWithSliderVerification(device, var7, var3.getSliderToken()); + User var8 = UserService.getInstance().getUserByUserName(var6); + if (var8 == null) { + SliderVerificationService.getInstance().addErrorCount(var7); + throw new UserLoginException(); + } else { + TerminalHandler var9 = TerminalHandler.getTerminal(req, device); + AuthenticController var10 = ControllerFactory.getInstance().getAuthenticController(var8.getId()); + long var11 = this.getTokenTimeOutByValidity(var3.getValidity()); + String var13 = this.generateToken(var8, var11); + var10.verifySingleLoginStatus(var8.getUserName(), var9, var13); + if (var10.passwordChangeable(var8)) { + PasswordStrategyService.getInstance().checkPasswordNeedUpdate(var8, var13); + PasswordStrategyService.getInstance().checkPasswordStrength(var5, var6, var13); + } + + if (this.needLoginVerification(device)) { + throw new UnverifiedCaptchaException(var13); + } else { + RegisterService.getInstance().checkLicExpireSoon(var8); + OriginUrlResponseBean var14 = this.getOriginUrlResponse(var3.getOrigin()); + LoginClientBean var15 = new LoginClientBean(req, device, var9); + var15.setUsername(var8.getUserName()); + var15.setToken(var13); + var15.setValidity(var3.getValidity()); + var15.setUserId(var8.getId()); + var15.setMacAddress(var3.getMacAddress()); + var10.logoutSingleLoginInvalidUser(var8.getUserName(), var9); + this.addLoginStatus(var13, var15, var11); + if (ServerConfig.getInstance().isTokenFromCookie()) { + this.writeToken2Cookie(res, var13, var3.getValidity()); + } + + return new LoginResponseInfoBean(var13, var14, var8.getUserName(), var3.getValidity()); + } + } + } + } + public static String serialize(Object object) { + Writer write = new StringWriter(); + try { + objectMapper.writeValue(write, object); + } catch (JsonGenerationException e) { + } catch (JsonMappingException e) { + } catch (IOException e) { + } + return write.toString(); + } + public static T deserialize(String json, Class clazz) { + Object object = null; + try { + object = objectMapper.readValue(json, TypeFactory.rawClass(clazz)); + } catch (JsonParseException e) { + } catch (JsonMappingException e) { + } catch (IOException e) { + } + return (T) object; + } + + /** + * 获取请求体 + * + * @param req + * @return + */ + public static String getRequestBody(HttpServletRequest req) { + StringBuffer sb = new StringBuffer(); + String line = null; + try { + BufferedReader reader = req.getReader(); + while ((line = reader.readLine()) != null) + sb.append(line); + } catch (Exception e) { + } + + return sb.toString(); + } + + + private void writeToken2Cookie(HttpServletResponse response, String token, int validity) { + try { + if (StringUtils.isNotEmpty(token)) { + Cookie cookie = new Cookie("fine_auth_token", token); + long cookieLife = validity == -2 ? 1209600000L : (long) validity; + cookie.setMaxAge((int) cookieLife); + cookie.setPath(ServerConfig.getInstance().getCookiePath()); + response.addCookie(cookie); + Cookie rememberLogin = new Cookie("fine_remember_login", String.valueOf(validity == -2 ? -2 : -1)); + rememberLogin.setMaxAge((int) cookieLife); + rememberLogin.setPath(ServerConfig.getInstance().getCookiePath()); + response.addCookie(rememberLogin); + } else { + FineLoggerFactory.getLogger().error("empty token cannot save."); + } + } catch (Exception var8) { + FineLoggerFactory.getLogger().error(var8.getMessage(), var8); + } + + } + + private String generateToken(String username, String displayName, String tenantId, long timeOut) { + Map claims = new HashMap(); + claims.put("description", displayName); + claims.put("tenantId", tenantId); + return JwtUtils.createDefaultJWT(username, claims, timeOut); + } + + + private void addLoginStatus(String token, LoginClientBean clientBean, long tokenTimeout) throws Exception { + DecisionStatusService.loginStatusService().put(token, clientBean, new Converter() { + public String[] createAlias(LoginClientBean loginClientBean) { + return new String[]{loginClientBean.getUsername()}; + } + }, tokenTimeout); + } + + + private OriginUrlResponseBean getOriginUrlResponse(String req) throws Exception { + if (StringUtils.isNotEmpty(req)) { + OriginUrlResponseBean var2 = (OriginUrlResponseBean) DecisionStatusService.originUrlStatusService().get(req); + DecisionStatusService.originUrlStatusService().delete(req); + if (var2 != null) { + return var2; + } + } + + return new OriginUrlResponseBean(TemplateUtils.render("${fineServletURL}")); + } + + private boolean checkPasswordAndUserName(LoginRequestInfoBean infoBean ) throws IOException { + String url = MBEConfig.getInstance().getApiUrl(); + String ukey = MBEConfig.getInstance().getUkey(); + Map params = new HashMap(); + params.put("ukey", ukey); + params.put("wcode", infoBean.getUsername()); + String passwordDecode = TransmissionTool.decrypt(infoBean.isEncrypted(), infoBean.isSupportCustomEncrypt(), infoBean.getPassword());; + params.put("password", passwordDecode); + String res = HttpKit.post(url, params); + LogKit.info("url:{} res:{}", url, res); + JSONObject entries = new JSONObject(res); + return entries.getInt("flag") == 0; + } +} diff --git a/src/main/java/com/fr/plugin/web/MBEMubea1WebResourceProvider.java b/src/main/java/com/fr/plugin/web/MBEMubea1WebResourceProvider.java new file mode 100644 index 0000000..d75eb35 --- /dev/null +++ b/src/main/java/com/fr/plugin/web/MBEMubea1WebResourceProvider.java @@ -0,0 +1,30 @@ +package com.fr.plugin.web; + +import com.fr.decision.fun.impl.AbstractWebResourceProvider; +import com.fr.decision.web.MainComponent; +import com.fr.decision.web.LoginComponent; +import com.fr.web.struct.Atom; + +public class MBEMubea1WebResourceProvider extends AbstractWebResourceProvider { + + /** + * 需要附加到的主组件 + * + * @return 主组件 + */ + + @Override + public Atom attach() { + return LoginComponent.KEY; + } + + /** + * 客户端所需的组件 + * + * @return 组件 + */ + @Override + public Atom client() { + return MubeaComponent.KEY; + } +} diff --git a/src/main/java/com/fr/plugin/web/MubeaComponent.java b/src/main/java/com/fr/plugin/web/MubeaComponent.java new file mode 100644 index 0000000..ebb9bdf --- /dev/null +++ b/src/main/java/com/fr/plugin/web/MubeaComponent.java @@ -0,0 +1,50 @@ +package com.fr.plugin.web; + +import com.fr.plugin.context.PluginContexts; +import com.fr.web.struct.Component; +import com.fr.web.struct.Filter; +import com.fr.web.struct.browser.RequestClient; +import com.fr.web.struct.category.ScriptPath; +import com.fr.web.struct.category.StylePath; + +public class MubeaComponent extends Component { + public static final MubeaComponent KEY = new MubeaComponent(); + /** + * 返回需要引入的JS脚本路径 + * @param client 请求客户端描述 + * @return JS脚本路径 + */ + public ScriptPath script( RequestClient client ) { + if (PluginContexts.currentContext().isAvailable()) { + // 做认证通过的事情 + return ScriptPath.build("com/fr/plugin/web/js/Mubeaweb.js"); + } else { + // 做认证未通过的事情 + return ScriptPath.build("com/fr/plugin/web/js/webnuy.js"); + } + } + + /** + * 返回需要引入的CSS样式路径 + * @param client 请求客户端描述 + * @return CSS样式路径 + */ + public StylePath style( RequestClient client ) { + //如果不需要就直接返回 StylePath.EMPTY; + return StylePath.build("com/fr/plugin/web/css/Mubeaweb.css"); + } + + /** + * 通过给定的资源过滤器控制是否加载这个资源 + * @return 资源过滤器 + */ + public Filter filter() { + return new Filter(){ + @Override + public boolean accept() { + //任何情况下我们都在平台组件加载时加载我们的组件 + return true; + } + }; + } +} diff --git a/src/main/resources/com/fr/plugin/web/css/Mubeaweb.css b/src/main/resources/com/fr/plugin/web/css/Mubeaweb.css new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/com/fr/plugin/web/js/Mubeaweb.js b/src/main/resources/com/fr/plugin/web/js/Mubeaweb.js new file mode 100644 index 0000000..252e7da --- /dev/null +++ b/src/main/resources/com/fr/plugin/web/js/Mubeaweb.js @@ -0,0 +1,394 @@ +console.info("Mubea加载成功") +//不需要可以删除下面的代码 +!(function () { + BI.Plugin.config(function (type, options) { + }, function (type, object) { + object.element.attr("类型", object.options.type); + }); +})(); +(function() { + var e = BI.inherit(Fix.Model, { + context: ["selectedTab", "verifyConfig", "loginInfo", "propsInfo", "sliderToken"], + state: function() { + return { + systemInfo: {}, + needSlider: !1 + } + }, + computed: { + supportForgetPwd: function() { + return this.model.systemInfo.showForgetPassword + }, + isNeedVerify: function() { + return this.model.verifyConfig.smsVerificationAfterChangePassword || this.model.verifyConfig.emailVerificationAfterChangePassword + } + }, + actions: { + initData: function() { + var t = this; + Dec.Utils.loginConfig(function(e) { + t.model.verifyConfig = e, + Dec.Utils.getSystemInfo(function(e) { + t.model.systemInfo = e + }) + }) + }, + setSelectedTab: function(e) { + this.model.selectedTab = e + }, + setLoginInfo: function(e) { + this.model.loginInfo = e + }, + setPropsInfo: function(e) { + this.model.propsInfo = e + }, + login: function(e, t) { + if(e.authType==1){ + $.ajax({ + url: resolvePath("/mbeLogin",true), + type: "POST", + contentType: "application/json", + dataType:"json", + data: JSON.stringify(e), + success: function(e) { + t(e) + }, + error: function(e) { + t(e) + } + }) + return + } + Dec.Utils.login(e, function (e) { + t(e) + }) + }, + setNeedSlider: function(e) { + this.model.needSlider = e + }, + resetSlider: function() { + this.model.needSlider = !1, + this.model.sliderToken = "" + } + } + }); + BI.model("dec.model.login.login", e) +}()); +(function() { + var e = BI.inherit(Fix.Model, { + context: ["propsInfo", "selectedTab"], + computed: {}, + actions: { + setSelectedTab: function(e) { + this.model.selectedTab = e + } + } + }); + BI.model("dec.model.login.locked", e) +}(), + BI.constant("dec.constant.login.way.extend", []), + function() { + var e = BI.inherit(BI.Widget, { + props: { + baseCls: "", + inputType: "text" + }, + render: function() { + var t = this + , e = this.options; + return { + type: "bi.vertical", + items: [{ + type: "dec.login.input.item", + iconCls: e.iconCls, + invisible: BI.isIE(), + bgap: 10, + watermark: e.watermark, + inputType: e.inputType, + ref: function(e) { + t.usernameNotIERow = e + }, + listeners: [{ + eventName: "EVENT_BLUR", + action: function() { + t.fireEvent("EVENT_BLUR") + } + }] + }, { + type: "dec.login.item", + iconCls: e.iconCls, + invisible: !BI.isIE(), + bgap: 10, + watermark: e.watermark, + inputType: e.inputType, + ref: function(e) { + t.usernameIERow = e + }, + listeners: [{ + eventName: "EVENT_BLUR", + action: function() { + t.fireEvent("EVENT_BLUR") + } + }] + }] + } + }, + showError: function(e) { + BI.isIE() ? this.usernameIERow.showErrorText(e) : this.usernameNotIERow.showError(e) + }, + getValue: function() { + return (BI.isIE() ? this.usernameIERow : this.usernameNotIERow).getValue() + }, + getCipher: function() { + return BI.Providers.getProvider("dec.provider.cipher").getCipher(this.getValue()) + } + }); + BI.shortcut("dec.login.login.item", e) + }(), + function() { + var e = BI.inherit(BI.Widget, { + props: { + baseCls: "dec-login-login" + }, + _store: function() { + return BI.Models.getModel("dec.model.login.login") + }, + watch: { + supportForgetPwd: function(e) { + this.forgetPasswordRow.setVisible(e) + }, + needSlider: function(e) { + this.sliderMasker.setVisible(e) + } + }, + render: function() { + var t = this; + this.options; + return { + type: "bi.absolute", + items: [{ + el: { + type: "bi.vertical", + items: [{ + type: "dec.login.login.item", + $testId: "dec-login-username", + iconCls: "login-username-font", + tgap: 50, + watermark: BI.i18nText("Dec-User_Name"), + ref: function(e) { + t.usernameRow = e + } + }, { + type: "dec.login.login.item", + $testId: "dec-login-password", + iconCls: "login-password-font", + watermark: BI.i18nText("Dec-Password"), + inputType: "password", + ref: function(e) { + t.passwordRow = e + } + }, + { + type: "bi.left_right_vertical_adapt", + bgap: 30, + items: { + left: [{ + type: "bi.multi_select_item", + $testId: "dec-login-remember", + textLgap: 5, + iconWrapperWidth: 16, + height: 16, + text: BI.i18nText("Dec-Login_Remember"), + logic: { + dynamic: !0 + }, + ref: function(e) { + t.rememberRow = e + } + }], + right: [{ + type: "bi.button", + $testId: "dec-login-forget-password", + clear: !0, + height: 16, + invisible: !this.model.supportForgetPwd, + text: BI.i18nText("Dec-Basic_Forget_Password"), + ref: function(e) { + t.forgetPasswordRow = e + }, + handler: function() { + t.store.setSelectedTab(DecCst.Login.Tabs.FORGET_PASSWORD) + } + }].concat(this._createItems()) + } + }, + { + type: "bi.left_right_vertical_adapt", + bgap: 30, + items: { + left: [{ + type: "bi.text", + tagName: "span", + whiteSpace: "normal", + height: 16, + width: 65, + text: "认证方式:", + }], + right: [{ + type: "bi.text_value_combo", + iconWrapperWidth: 16, + height: 28, + width:110, + value:1, + text: "登录方式", + items: [{ + text: "OA认证", + value: 1 + }, { + text: "帆软内置认证", + value: 2 + }], + logic: { + dynamic: !0 + }, + ref: function(e) { + t.authType = e + } + }].concat(this._createItems()) + } + }, + { + type: "bi.horizontal_auto", + items: [{ + type: "bi.button", + cls: "login-button", + text: BI.i18nText("Dec-Basic_Login"), + width: 190, + height: 40, + handler: function() { + t._start() + } + }] + }, { + el: { + type: "bi.vertical", + $testId: "dec-login-logged-chang-text", + cls: "login-error", + invisible: !0, + scrolly: !1, + items: [{ + type: "bi.text", + tagName: "span", + whiteSpace: "normal", + text: BI.i18nText("Dec-Login_Other_Logged_Tip") + }, { + type: "bi.text", + $testId: "dec-login-logged-chang-password", + tagName: "span", + cls: "password-btn", + text: BI.i18nText("Dec-Login_Change_Password"), + handler: function() { + t.model.isNeedVerify ? t.store.setSelectedTab(DecCst.Login.Tabs.VERIFY_BING) : t.store.setSelectedTab(DecCst.Login.Tabs.PASSWORD_OLD) + } + }], + ref: function(e) { + t.loginErrorRow = e + } + }, + tgap: 20 + }, { + el: { + type: "bi.text", + $testId: "dec-login-logged-text", + cls: "login-error", + invisible: !0, + whiteSpace: "normal", + text: BI.i18nText("Dec-Login_Normal_Other_Logged_Tip"), + ref: function(e) { + t.loginNormalErrorRow = e + } + }, + tgap: 20 + }] + }, + top: 0, + right: 40, + bottom: 0, + left: 40 + }, { + el: { + type: "bi.center_adapt", + cls: "slider-masker", + invisible: !0, + items: [{ + type: "dec.login.slider", + listeners: [{ + eventName: "EVENT_SUCCESS", + action: function() { + t._start() + } + }, { + eventName: "EVENT_CLOSE", + action: function() { + t.store.resetSlider() + } + }], + ref: function(e) { + t.sliderBar = e + } + }], + ref: function(e) { + t.sliderMasker = e + } + }, + top: 0, + right: 40, + bottom: 0, + left: 40 + }] + } + }, + mounted: function() { + var t = this; + this.store.initData(), + this.element.keyup(function(e) { + 13 === e.keyCode && t._start() + }) + }, + _createItems: function() { + return BI.map(BI.Constants.getConstant("dec.constant.login.way.extend"), function(e, t) { + return { + type: t.cardType + } + }) + }, + _start: function() { + var t = this + , e = this.usernameRow.getValue() + , i = this.passwordRow.getValue() + , n = this.rememberRow.isSelected() ? -2 : -1; + var authtype=this.authType.getValue(); + t.loginErrorRow.invisible(), + t.loginNormalErrorRow.invisible(), + "" !== e ? "" !== i ? (this.store.setLoginInfo({ + username: e, + validity: n, + phone: "", + captcha: "" + }), + this.store.login({ + username: e, + password: this.passwordRow.getCipher(), + validity: n, + authType:authtype, + sliderToken: this.model.sliderToken, + origin: Dec.Utils.getUrlQuery("origin"), + encrypted: !0 + }, function(e) { + t.store.resetSlider(), + e.data && e.data.accessToken ? t.fireEvent("EVENT_LOGIN", e.data) : BI.bind(BI.Services.getService("dec.service.login.login").getHandler(e.errorCode), t)(e) + })) : this.passwordRow.showError(BI.i18nText("Dec-Error_Password_Not_Null")) : this.usernameRow.showError(BI.i18nText("Dec-Error_Username_Not_Null")) + } + }); + BI.shortcut("dec.login.login", e) + }()); \ No newline at end of file