修改相关业务操作数据文件,对用户注册和增加用户暂时进行md5加密,然后存入到数据表中

This commit is contained in:
wanglei 2025-11-04 21:57:42 +08:00
parent f807eb10fd
commit c9845b7552
11 changed files with 23 additions and 16 deletions

View File

@ -24,10 +24,10 @@ http {
# The verification depth in the server certificates chain.
#lua_ssl_verify_depth 3;
# Nginx 启动时执行的 Lua 代码块
#Nginx启动时执行的Lua代码块
lua_shared_dict dict_a 1m;
init_by_lua_block {
-- 定义一个全局变量
-- 定义一个全局变量
ngx.log(ngx.INFO, "Initializing global variable")
global_var = "Hello, Nginx with Lua!"
@ -35,8 +35,8 @@ http {
local shared_dict = ngx.shared.dict_a
shared_dict:set("key", "value")
}
#下面代码不能与上面的代码进行共用,否则报错nginx: [emerg] "init_by_lua_file" directive is duplicate
#init_by_lua_block init_by_lua_file 只能初始化其中的一个,不能同时启用
#否则报错nginx: [emerg] "init_by_lua_file" directive is duplicate
#init_by_lua_file '/home/frankly/work/AuthPlatform/src/init.lua';
server {

View File

@ -11,7 +11,7 @@ local systemAccount = require("service.system.account")
--定义相关路由前端接口url地址
local routes = {
--户相关路由接口
--户相关路由接口
{
paths = { "/api/system/accounts" },
methods = { "GET" },

View File

@ -11,7 +11,7 @@ local systemApplication = require("service.system.application")
--定义相关路由前端接口url地址
local routes = {
--相关路由接口
--用相关路由接口
{
paths = { "/api/system/applications" },
methods = { "GET" },

View File

@ -11,7 +11,7 @@ local systemDepartment = require("service.system.department")
--定义相关路由前端接口url地址
local routes = {
--用户相关路由接口
--组织(部门)相关路由接口
{
paths = { "/api/system/departments" },
methods = { "GET" },

View File

@ -11,7 +11,7 @@ local systemMenu = require("service.system.menu")
--定义相关路由前端接口url地址
local routes = {
--用户相关路由接口
--菜单相关路由接口
{
paths = { "/api/system/menus" },
methods = { "GET" },

View File

@ -11,7 +11,7 @@ local systemPermission = require("service.system.permission")
--定义相关路由前端接口url地址
local routes = {
--用户相关路由接口
--权限相关路由接口
{
paths = { "/api/system/permissions" },
methods = { "GET" },

View File

@ -11,7 +11,7 @@ local systemPosition = require("service.system.position")
--定义相关路由前端接口url地址
local routes = {
--用户相关路由接口
--岗位相关路由接口
{
paths = { "/api/system/positions" },
methods = { "GET" },

View File

@ -11,7 +11,7 @@ local systemRole = require("service.system.role")
--定义相关路由前端接口url地址
local routes = {
--用户相关路由接口
--角色相关路由接口
{
paths = { "/api/system/roles" },
methods = { "GET" },

View File

@ -20,18 +20,19 @@ local function authenticate(name, passwd)
if passwd == "" then
return 0x010002, nil
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
return code, res
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
return code, res
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
return code, res
end

View File

@ -15,7 +15,6 @@ local _M = {}
local user = {
["ID"] = "",
["type"] = 0,
}
--判断用户是否存在
@ -72,6 +71,9 @@ function _M.addSystemUser(jsonData)
--键值为id产生uuid数据值增加到json中
jsonData.id = helpers.getUuid()
--用户密码暂时使用md5进行加密
local pwd = jsonData['password']
jsonData.password = ngx.encode_md5(pwd)
-- 创建一个用户
return userModel:create(jsonData)
end

View File

@ -3,9 +3,13 @@
--- Created by frankly.
--- DateTime: 2025/11/3 18:44
---
--[[
"ngx_lua""init_by_lua_file";
nginx时初始化一次
--]]
print("init application...")
--初始化获取系统默认的用户权限为实现RBAC框架做权限数据准备
cjson = require "cjson"
local dict_a = ngx.shared.dict_a
local v = dict_a:get("abc")