As mentioned, through oauth authorization, some basic information is obtained: user name, user avatar, email
What will the design look like after that?
The password field in the user table has been set to not empty, and the user name is set to unique. The obtained information cannot be directly stored , the user foreign key in the openid table is not easy to get. In addition, does the obtained user avatar need to be downloaded locally? Can anyone give me an idea? Thank you
Reply content:
As mentioned, through oauth authorization, some basic information is obtained: user name, user avatar, email
What will the design look like after that?
The password field in the user table has been set to not empty, and the user name is set to unique. The obtained information cannot be directly stored , the user foreign key in the openid table is not easy to get. In addition, does the obtained user avatar need to be downloaded locally? Can anyone give me an idea? Thank you
Correction: After the next batch of oauth authorization, the user information obtained is not called the user name. For the local system, it should be called "nickname"
Then it should not affect the user table used by the local system. It should exist as the appearance of the user table, similar to the following
user table
user_id, username, password
user_openid table
user_openid_id,openid,openid_type,user_id,nickname,avatar,email
The authorization login process is roughly as follows. The specific needs are determined according to the product business logic. There are many design methods
Information obtained after authorized login from QQ, Weibo, WeChat, etc.
Determine whether openid exists in user_openid. If it does not exist, save it first. If it exists, determine whether there is a user_id. If so, log in. If not, complete the registration information required for the user table. It is similar to registering and binding. Three-party login account
Generally, there is a place in the user center where you can bind other third-party accounts, similar to segmentfault
After completing the above steps, you can support normal username and password login and all third-party account logins
It is also recommended to consider some other detailed scenarios based on business logic
As for whether the avatar can be saved or not, generally the avatar address provided by the third-party account will not expire. If you encounter specific problems in your product, you can optimize it

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver Mac version
Visual web development tools

Atom editor mac version download
The most popular open source editor
