修改相关业务操作数据文件,对用户注册和增加用户暂时进行md5加密,然后存入到数据表中
This commit is contained in:
parent
f807eb10fd
commit
c9845b7552
|
|
@ -35,8 +35,8 @@ http {
|
||||||
local shared_dict = ngx.shared.dict_a
|
local shared_dict = ngx.shared.dict_a
|
||||||
shared_dict:set("key", "value")
|
shared_dict:set("key", "value")
|
||||||
}
|
}
|
||||||
|
#init_by_lua_block 与 init_by_lua_file 只能初始化其中的一个,不能同时启用
|
||||||
#下面代码不能与上面的代码进行共用,否则报错nginx: [emerg] "init_by_lua_file" directive is duplicate
|
#否则报错nginx: [emerg] "init_by_lua_file" directive is duplicate
|
||||||
#init_by_lua_file '/home/frankly/work/AuthPlatform/src/init.lua';
|
#init_by_lua_file '/home/frankly/work/AuthPlatform/src/init.lua';
|
||||||
|
|
||||||
server {
|
server {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ local systemAccount = require("service.system.account")
|
||||||
|
|
||||||
--定义相关路由,前端接口url地址
|
--定义相关路由,前端接口url地址
|
||||||
local routes = {
|
local routes = {
|
||||||
--用户相关路由接口
|
--账户相关路由接口
|
||||||
{
|
{
|
||||||
paths = { "/api/system/accounts" },
|
paths = { "/api/system/accounts" },
|
||||||
methods = { "GET" },
|
methods = { "GET" },
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ local systemApplication = require("service.system.application")
|
||||||
|
|
||||||
--定义相关路由,前端接口url地址
|
--定义相关路由,前端接口url地址
|
||||||
local routes = {
|
local routes = {
|
||||||
--用户相关路由接口
|
--应用相关路由接口
|
||||||
{
|
{
|
||||||
paths = { "/api/system/applications" },
|
paths = { "/api/system/applications" },
|
||||||
methods = { "GET" },
|
methods = { "GET" },
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ local systemDepartment = require("service.system.department")
|
||||||
|
|
||||||
--定义相关路由,前端接口url地址
|
--定义相关路由,前端接口url地址
|
||||||
local routes = {
|
local routes = {
|
||||||
--用户相关路由接口
|
--组织(部门)相关路由接口
|
||||||
{
|
{
|
||||||
paths = { "/api/system/departments" },
|
paths = { "/api/system/departments" },
|
||||||
methods = { "GET" },
|
methods = { "GET" },
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ local systemMenu = require("service.system.menu")
|
||||||
|
|
||||||
--定义相关路由,前端接口url地址
|
--定义相关路由,前端接口url地址
|
||||||
local routes = {
|
local routes = {
|
||||||
--用户相关路由接口
|
--菜单相关路由接口
|
||||||
{
|
{
|
||||||
paths = { "/api/system/menus" },
|
paths = { "/api/system/menus" },
|
||||||
methods = { "GET" },
|
methods = { "GET" },
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ local systemPermission = require("service.system.permission")
|
||||||
|
|
||||||
--定义相关路由,前端接口url地址
|
--定义相关路由,前端接口url地址
|
||||||
local routes = {
|
local routes = {
|
||||||
--用户相关路由接口
|
--权限相关路由接口
|
||||||
{
|
{
|
||||||
paths = { "/api/system/permissions" },
|
paths = { "/api/system/permissions" },
|
||||||
methods = { "GET" },
|
methods = { "GET" },
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ local systemPosition = require("service.system.position")
|
||||||
|
|
||||||
--定义相关路由,前端接口url地址
|
--定义相关路由,前端接口url地址
|
||||||
local routes = {
|
local routes = {
|
||||||
--用户相关路由接口
|
--岗位相关路由接口
|
||||||
{
|
{
|
||||||
paths = { "/api/system/positions" },
|
paths = { "/api/system/positions" },
|
||||||
methods = { "GET" },
|
methods = { "GET" },
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ local systemRole = require("service.system.role")
|
||||||
|
|
||||||
--定义相关路由,前端接口url地址
|
--定义相关路由,前端接口url地址
|
||||||
local routes = {
|
local routes = {
|
||||||
--用户相关路由接口
|
--角色相关路由接口
|
||||||
{
|
{
|
||||||
paths = { "/api/system/roles" },
|
paths = { "/api/system/roles" },
|
||||||
methods = { "GET" },
|
methods = { "GET" },
|
||||||
|
|
|
||||||
|
|
@ -20,18 +20,19 @@ local function authenticate(name, passwd)
|
||||||
if passwd == "" then
|
if passwd == "" then
|
||||||
return 0x010002, nil
|
return 0x010002, nil
|
||||||
end
|
end
|
||||||
|
local pwdMd5 = ngx.encode_md5(passwd)
|
||||||
--根据用户进行验证用户是否存在
|
--根据用户进行验证用户是否存在
|
||||||
local code, res = userModel:where("username", "=", name):where("password", "=", passwd):get()
|
local code, res = userModel:where("username", "=", name):where("password", "=", pwdMd5):get()
|
||||||
if code == 0 and res ~= nil then
|
if code == 0 and res ~= nil then
|
||||||
return code, res
|
return code, res
|
||||||
end
|
end
|
||||||
--根据手机号进行验证用户是否存在
|
--根据手机号进行验证用户是否存在
|
||||||
code, res = userModel:where("phone", "=", name):where("password", "=", passwd):get()
|
code, res = userModel:where("phone", "=", name):where("password", "=", pwdMd5):get()
|
||||||
if code == 0 and res ~= nil then
|
if code == 0 and res ~= nil then
|
||||||
return code, res
|
return code, res
|
||||||
end
|
end
|
||||||
--根据邮箱进行验证用户是否存在
|
--根据邮箱进行验证用户是否存在
|
||||||
code, res = userModel:where("email", "=", name):where("password", "=", passwd):get()
|
code, res = userModel:where("email", "=", name):where("password", "=", pwdMd5):get()
|
||||||
if code == 0 and res ~= nil then
|
if code == 0 and res ~= nil then
|
||||||
return code, res
|
return code, res
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ local _M = {}
|
||||||
local user = {
|
local user = {
|
||||||
["ID"] = "",
|
["ID"] = "",
|
||||||
["type"] = 0,
|
["type"] = 0,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
--判断用户是否存在
|
--判断用户是否存在
|
||||||
|
|
@ -72,6 +71,9 @@ function _M.addSystemUser(jsonData)
|
||||||
|
|
||||||
--键值为id产生uuid数据值,增加到json中
|
--键值为id产生uuid数据值,增加到json中
|
||||||
jsonData.id = helpers.getUuid()
|
jsonData.id = helpers.getUuid()
|
||||||
|
--用户密码暂时使用md5进行加密
|
||||||
|
local pwd = jsonData['password']
|
||||||
|
jsonData.password = ngx.encode_md5(pwd)
|
||||||
-- 创建一个用户
|
-- 创建一个用户
|
||||||
return userModel:create(jsonData)
|
return userModel:create(jsonData)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,13 @@
|
||||||
--- Created by frankly.
|
--- Created by frankly.
|
||||||
--- DateTime: 2025/11/3 18:44
|
--- DateTime: 2025/11/3 18:44
|
||||||
---
|
---
|
||||||
|
--[[
|
||||||
|
在"ngx_lua"模块的"init_by_lua_file"命令中执行;
|
||||||
|
只在启动nginx时初始化一次。
|
||||||
|
--]]
|
||||||
|
|
||||||
print("init application...")
|
print("init application...")
|
||||||
|
--初始化,获取系统默认的用户权限,为实现RBAC框架做权限数据准备
|
||||||
cjson = require "cjson"
|
cjson = require "cjson"
|
||||||
local dict_a = ngx.shared.dict_a
|
local dict_a = ngx.shared.dict_a
|
||||||
local v = dict_a:get("abc")
|
local v = dict_a:get("abc")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user