strapi 自带的User表注册及登录实现方法

59 阅读1分钟

strapi官方接口 strapi.nodejs.cn/cms/feature…

注册(postmen调用注意Headers中加 Content-Type: application/json ):

接口url:http://localhost:1337/api/auth/local/register

#入参 { "username": "ces", "password": "123456", "email": "123456@163.com" }

注册接口调用成功

image.png

可在控制台进行接口授权

image.png

登录:

接口url:http://localhost:1337/api/auth/local

#入参 { "identifier": "user@strapi.io", "password": "strapiPassword"} #返回参数 { "jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiaWF0IjoxNTc2OTM4MTUwLCJleHAiOjE1Nzk1MzAxNTB9.UgsjjXkAZ-anD257BF7y1hbjuY3ogNceKfTAQtzDEsU", "user": { "id": 1, "username": "user", ... }}