小程序的用户登录逻辑怎么写?

小程序 文章 2022-01-04 12:20 310 0 全屏看文

AI助手支持GPT4.0

小程序的用户登录逻辑怎么写?How to write the user login logic of the applet?

小程序的用户登录逻辑怎么写?

写了一个主要是对内部员工开发的小程序,新用户通过短信验证,在数据库创建新的用户信息,其中包含了用户的OPENID,用于用户后续登录自动鉴权。

但希望实现每次打开小程序,在app.js中一次鉴权,所有页面直接调用。

但逻辑有点问题,请各位大佬指教,谢谢。


A small program mainly developed for internal employees is written. New users create new user information in the database through SMS authentication, including the user's openid for automatic authentication of subsequent login. But I hope to open the applet every time in app JS, all pages can be called directly. But there is something wrong with the logic. Please give me some advice. Thank you.

回答:

李伟豪:

存在的问题,跟我之前遇到一模一样。这是我们在用的方案,希望能帮到你。

https://developers.weixin.qq.com/community/develop/article/doc/000e6832d38bf0e0494df513154413

困难:

查询数据库用async await转为同步的也不行吗?

garField:

1,用户信息(比如token)存到 localstorage,这样退出小程序也不会被清除;

2,你们的后端接口有验证权限吗?如果有,在返回没有权限的时候,再跳转到登录页。

-EOF-

AI助手支持GPT4.0