首页 > 其他分享 >SAP 电商云 Spartacus UI userID 即邮件地址中的加号问题

SAP 电商云 Spartacus UI userID 即邮件地址中的加号问题

时间:2022-09-23 23:35:21浏览次数:78  
标签:credential 电商 HTTP Spartacus getMessage new credentials SAP String

如果用户登录名或密码包含符号 +,它将被替换为空格,因为 Content-Type 等于 application/x-www-form-urlencoded。

下面是一个例子:

https://:9002/occ/v2/electronics-spa/forgottenpasswordtokens?lang=en&curr=USD

我输入了包含 + 号的邮件地址后,点击 Submit,发送一个 HTTP POST 请求到后台,响应为 202:

从 Form Data 区域,我们可以发现,这个 userId 显示为 a @sap.com, 邮箱地址里包含了空格符号:

找到 Reset Password Component 的 selector:cx-forgot-password

Component 名称为:ForgotPasswordComponent

通过 Service 实现:

依赖于 UserPasswordFacade:

调用 userProfileConnector 完成:

connector 调用 userProfileAdapter:

这是一个 abstract class,我们调用 OCCUserProfileAdapter 实现:

OccUserProfileAdapter 最终调用 HTTP Client 的 post 操作:

我们在后台打印 Angular HTTP client 发送过来的请求,发现确实 + 号被转换成了空格:

https://github.com/angular/angular/blob/8.2.4/packages/common/http/src/params.ts#L81

这个文件首先使用浏览器的 encodeURIComponent() 方法,但随后恢复了几个字符的编码,包括 + 号。

一种比较合理的设计是:

感谢@meeque 参与讨论这个话题。 Angular 确实不支持干净的编码/解码,这就是为什么我们没有为各种字符(@

标签:credential,电商,HTTP,Spartacus,getMessage,new,credentials,SAP,String
From: https://www.cnblogs.com/sap-jerry/p/16724643.html

相关文章