当前位置: 首页 > news >正文

网站推广的方法有哪几种外贸企业网站建设方案

网站推广的方法有哪几种,外贸企业网站建设方案,企业 网站备案 法人,蓝色扁平化网站在项目中#xff0c;前后端分离的若依项目#xff0c;需要通过统一认证#xff0c;或者是第三方协带认证信息跳转到本系统的指定页面。需要前后端都做相应的改造#xff0c;由于第一次实现时已过了很久#xff0c;再次重写时#xff0c;发现还是搞了很长时间#xff0c;…在项目中前后端分离的若依项目需要通过统一认证或者是第三方协带认证信息跳转到本系统的指定页面。需要前后端都做相应的改造由于第一次实现时已过了很久再次重写时发现还是搞了很长时间所以花点时间整理出事也方便给大家参考。 首先明确需要处理几个部分 一、后端的处理 1、 在控制器层SysLoginController  中原有的login方法之后写一个登录的方法注意其中的 loginService.logingcy(userId); 这个是下一步要实现的。通过第三方协议解析出用户的信息可能 是工号或者是微信的openid这都无所谓反正通过他你能找到本系统的用户就可以了。 GetMapping(/logingcy)public AjaxResult logingcy(String ssouser){AjaxResult ajax AjaxResult.success();try {//通过中间的协议解析出用户的基本信息String[] userInfo JasmineSsoUtil.getUserInfo(ssouser, Constants.SSODOMAIN, Constants.SSOKEY);String userId userInfo[0];//以下为获取此员工的待办工单数量并按要求返回值System.out.println(useris userId);String token loginService.logingcy(userId);ajax.put(Constants.TOKEN, token);return ajax;} catch (Exception e) {e.printStackTrace();}return AjaxResult.error();// 生成令牌} 2、在登录服务中增加一个和原来登录对应的方法 SysLoginService   loginService.logingcy(userId); /*通过工程翼用户登录*/public String logingcy(String username){// 用户验证Authentication authentication null;SysUser sysUser userService.selectUserByUserName(username);System.out.println(admin staffcode is username and password is sysUser.getPassword());try{//已经确认解析出用户信息所以这里使用一个内部的特定密码和模拟密码进行检验userDetailsService.loadUserByUsername(username);UsernamePasswordAuthenticationToken token new UsernamePasswordAuthenticationToken(username, Constants.CPASSWORD);//AuthenticationContextHolder.setContext(token);// 该方法会去调用UserDetailsServiceImpl.loadUserByUsernameauthentication authenticationManager.authenticate(token);}catch (Exception e){if (e instanceof BadCredentialsException){AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message(user.password.not.match)));throw new UserPasswordNotMatchException();}else{AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));throw new ServiceException(e.getMessage());}}finally{// AuthenticationContextHolder.clearContext();}AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message(user.login.success)));LoginUser loginUser (LoginUser) authentication.getPrincipal();// 生成tokenreturn tokenService.createToken(loginUser);} 3、增加一个 SecurityProvider 用于密码和校检 具体的代码如下 package com.ruoyi.framework.security.provider;import com.ruoyi.common.constant.Constants; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.exception.user.UserPasswordNotMatchException; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.system.service.ISysUserService; import org.apache.poi.hssf.record.DVALRecord; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.*; import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.stereotype.Service;/*** 自定义认证服务* */ Service(securityProvider) public class SecurityProvider implements AuthenticationProvider {Autowiredprivate BCryptPasswordEncoder bCryptPasswordEncoder;Autowiredprivate UserDetailsService userDetailsService;Autowiredprivate ISysUserService userService;public SecurityProvider(UserDetailsService userDetailsService) {this.userDetailsService userDetailsService;}Overridepublic Authentication authenticate(Authentication authentication) throws AuthenticationException {/* UsernamePasswordAuthenticationToken token (UsernamePasswordAuthenticationToken) authentication;*/String name authentication.getName();String password (String) authentication.getCredentials();System.out.println(name:namepasswordpassword);//这里直接判断异常UserDetails user userDetailsService.loadUserByUsername(name);String encoderPassword bCryptPasswordEncoder.encode(password);SysUser user1 userService.selectUserByUserName(admin);user1.setPassword(SecurityUtils.encryptPassword(admin123));userService.updateUser(user1);System.out.println(1password is SecurityUtils.encryptPassword(password));System.out.println(2password isencoderPassword);System.out.println(user passwordis user.getPassword());// 数据库账号密码的校验能通过就通过if (SecurityUtils.matchesPassword(password, user.getPassword())){// if (bCryptPasswordEncoder.matches(password, user.getPassword())) {// log.info(使用账户密码登录);return new UsernamePasswordAuthenticationToken(user, encoderPassword);}//这里是第三方登录的使用方式用一个内部的密码代替了password的位置// log.info(checkValid);if(Constants.CPASSWORD.equalsIgnoreCase(password)){return new UsernamePasswordAuthenticationToken(user, password);} else {// 如果都登录不了就返回异常输出throw new UserPasswordNotMatchException();}}Overridepublic boolean supports(Class? authentication) {//返回true后才会执行上面的authenticate方法,这步能确保authentication能正确转换类型return true;}} 4、修改配置文件  SecurityConfig 有两处需要修改一个是最下面使用上一步定义的SecurityProvider 一个是上面允许前端的新登录页面可以直接访问 到此后端部分的改造就完成了。 二、前端页面 1、首先要做一个登录过度页面内容可以为空白只需要接收地址栏中的参数并且调用上面第一步中定义的方法 2、在路由中配置路径对应访问的这个页面 3、设置白名单可以直接访问页面 4、在原来的login.js中写入后台对应的地址这里注意需要先logou一下防止重复登录报错 export function logingcy(ssouser) {logout();return request({url: /logingcy?ssouser ssouser,method: get,}) } 5、在user.js中增加一个action这里需要写入token是关键不然后台一直报未登录
http://www.sczhlp.com/news/178224/

相关文章:

  • 全国购网站建设怎么在微信做企业网站
  • 手机网站的好外食品行业网站源码
  • 海珠区建网站黄页网云南企业
  • 做门票的网站四川省建筑施工企业特种作业人员
  • 要屏蔽一个网站要怎么做企业管理专业学什么
  • 建设银行江苏省分行网站网站空间域名续费合同
  • 网站建设脱颖而出昆明最新新闻事件今天
  • wordpress电子商城只有单页面的网站怎么做seo
  • 网站建设书店用户分几类做cpa怎么建立自己网站
  • 详细学习 HTML5 Canvas 这一篇文章就够了
  • 2025 年国内包装印刷制造厂家最新推荐排行榜:聚焦设备、团队与服务,精选优质企业助力合作决策礼盒/定制/设计/优质/品质包装印刷厂家推荐
  • Microsoft .NET Framework 3.5,4.5,4.8 版本下载,附Microsoft Visual C++微软官方运行库下载
  • 2025 年最新工业冷水机厂家排行榜:风冷式 / 螺杆式 / 实验室等多类型冷水机优质厂家最新推荐
  • 网站内存不足买公司 网站建设
  • 网站网站二维码收钱怎么做的开发公司移交给物业的资料说明
  • seo整站优化推广国有企业查询系统官网
  • 做海免费素材网站佛山整合营销
  • 学校网站建设自查报告商标注册申请要多少钱
  • 自己买域名建设网站承德网站建设步骤
  • ppt下载模板免费网站重庆江北区网站建设公司
  • 学校 网站源码wordpress 雪花插件
  • 一个做微信文章的网站品牌手机网站开发
  • 乐清微网站建设石家庄做网站制作公司
  • 专为网站做点击量怎么用自己的电脑做网站
  • 网站收录没图片做个网站需要多少钱
  • 定制网站多少钱海外 国内网站建设
  • 建设网站大概需要多少钱类似pinterest的网站
  • 四川蓉和建设公司网站做网站没有公网
  • 郑州网站备案wordpress 分页按钮
  • 在线销售型网站网站登录注册怎么做的