Skip to content

优化建议:/thirdLogin/{source}/callback 接口在签名校验失败时返回失败的标识码 #1441

Closed
@tanpenggood

Description

@tanpenggood
版本号:

2.2.1

问题描述:

使用第三方登录时,签名校验失败response.getCode() != 2000,后端 FreeMarker 报错,前端登录窗口也不会正常关闭。

建议:在签名校验失败时返回失败的token标识码,从而避免 FreeMarker 报错,前端根据失败的token标识码判断进行提示。

// 后端
if(response.getCode()==2000) {
  // ...
} else {
  modelMap.addAttribute("token", "失败的token标识码");
}

// 前端
let receiveMessage = function(event){
  let token = event.data
  if (token === '失败的token标识码') {
    alert('登录失败')
   } else {
    // 正常处理
   }
}
截图&代码:
2020-07-12 16:10:34.804 [http-nio-8080-exec-2] ERROR freemarker.runtime:59 - Error executing FreeMarker template
freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
==> token  [in template "thirdLogin.ftl" at line 14, column 37]

----
Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----

----
FTL stack trace ("~" means nesting-related):
	- Failed at: ${token}  [in template "thirdLogin.ftl" at line 14, column 35]
----
	at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:134)

Activity

1298191366

1298191366 commented on Jul 30, 2020

@1298191366
Contributor

已修改,待新版本发布

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @zhangdaiscott@1298191366@tanpenggood

        Issue actions

          优化建议:/thirdLogin/{source}/callback 接口在签名校验失败时返回失败的标识码 · Issue #1441 · jeecgboot/JeecgBoot