Mini Program login status to maintain (has its own third-party account)?

problem description

I read Mini Program"s wx.login and wx.checkSession , wx.login and then let the backend go to the interface provided by Tencent in exchange for session_key, and generate a sessionid to keep the login status. The current situation of
wx.checkSession is like this. Our project started on the web, and now we are going to migrate to Mini Program. This system has its own account password. In that case, can I not use wx.login , wx.checkSession . Is this reasonable (because I don"t use openid as my user ID)? My idea is that after the user logs in, the sessionid obtained from the server is saved to storage , and then used to set the header, but now I am faced with another problem. I can encapsulate wx.request and judge whether session is still valid, but if there is no maintenance of openid , it may require the user to re-log in. If you do not want the user to re-enter it, you may have to storage to save the account password and send it again? (is it not reasonable?)
has also had a reasonable idea to use wx.login in exchange for session , openid and our system account. After that, log in and directly use openid,
to solve this kind of problem. What is the better way to solve this kind of problem? I hope someone can give me some answers.

Oct.12,2021

  1. discard openid
    this is the easiest. Go directly to Mini Program and do a login registration page by yourself. After logging in and registering, there is a sessionid to return to the backstage and put Mini Program in the header of wx.request. The backend continues every time the sessionid, is valid in the requested header, and returns the corresponding information to Mini Program for re-login if it is not valid or not.
    but many of Mini Program's functions are not available. There are a lot of things to fill in on the registration page.
  2. is not recommended
  3. the original system extension is compatible with openId.

    • create a new table to store the user openId, associated user table.
    • Mini Program wx.login + user information + mobile phone number = "get from the background: openid, user information, mobile phone number.
    • check whether the current mobile phone number in the database is registered according to the mobile phone number.

      • if you have already registered, just add openid, and directly return the current user-generated sessionid to Mini Program.
      • if you do not register, a new user is created. The user name and password are all mobile phone numbers. The opendi is stored, and then the sessionid is generated and returned to Mini Program.
Menu