Skip to content

Commit

Permalink
refactor: added controller for users, removed old code
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Oct 27, 2023
1 parent 326d902 commit 93cddb2
Show file tree
Hide file tree
Showing 9 changed files with 425 additions and 317 deletions.
7 changes: 7 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ server {
rewrite admin/api/group/members /admin/api/index.php last;
rewrite admin/api/group/permissions /admin/api/index.php last;
rewrite admin/api/search/term /admin/api/index.php last;
rewrite admin/api/user/users /admin/api/index.php last;
rewrite admin/api/user/activate /admin/api/index.php last;
rewrite admin/api/user/add /admin/api/index.php last;
rewrite admin/api/user/data /admin/api/index.php last;
rewrite admin/api/user/delete /admin/api/index.php last;
rewrite admin/api/user/permissions /admin/api/index.php last;
rewrite admin/api/user/overwrite-password /admin/api/index.php last;
rewrite admin/api/health-check /admin/api/index.php last;
rewrite admin/api/updates /admin/api/index.php last;
rewrite admin/api/update-check /admin/api/index.php last;
Expand Down
7 changes: 7 additions & 0 deletions phpmyfaq/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ RewriteRule admin/api/group/members admin/api/index.php
RewriteRule admin/api/group/permissions admin/api/index.php
RewriteRule admin/api/group/users admin/api/index.php
RewriteRule admin/api/search/term admin/api/index.php
RewriteRule admin/api/user/users admin/api/index.php
RewriteRule admin/api/user/activate admin/api/index.php
RewriteRule admin/api/user/add admin/api/index.php
RewriteRule admin/api/user/data admin/api/index.php
RewriteRule admin/api/user/delete admin/api/index.php
RewriteRule admin/api/user/permissions admin/api/index.php
RewriteRule admin/api/user/overwrite-password admin/api/index.php
RewriteRule admin/api/health-check admin/api/index.php
RewriteRule admin/api/versions admin/api/index.php
RewriteRule admin/api/update-check admin/api/index.php
Expand Down
302 changes: 0 additions & 302 deletions phpmyfaq/admin/api/user.php

This file was deleted.

8 changes: 4 additions & 4 deletions phpmyfaq/admin/assets/src/api/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

export const fetchUsers = async (userName) => {
return await fetch(`index.php?action=ajax&ajax=user&ajaxaction=get_user_list&q=${userName}`, {
return await fetch(`./api/user/users?filter=${userName}`, {
method: 'GET',
cache: 'no-cache',
headers: {
Expand All @@ -39,7 +39,7 @@ export const fetchUsers = async (userName) => {
};

export const fetchUserData = async (userId) => {
return await fetch(`index.php?action=ajax&ajax=user&ajaxaction=get_user_data&user_id=${userId}`, {
return await fetch(`./api/user/data/${userId}`, {
method: 'GET',
cache: 'no-cache',
headers: {
Expand All @@ -60,7 +60,7 @@ export const fetchUserData = async (userId) => {
};

export const fetchUserRights = async (userId) => {
return await fetch(`index.php?action=ajax&ajax=user&ajaxaction=get_user_rights&user_id=${userId}`, {
return await fetch(`./api/user/permissions/${userId}`, {
method: 'GET',
cache: 'no-cache',
headers: {
Expand All @@ -81,7 +81,7 @@ export const fetchUserRights = async (userId) => {
};

export const fetchAllUsers = async () => {
return await fetch('index.php?action=ajax&ajax=user&ajaxaction=get_all_user_data', {
return await fetch('./api/user/users', {
method: 'GET',
cache: 'no-cache',
headers: {
Expand Down
4 changes: 2 additions & 2 deletions phpmyfaq/admin/assets/src/user/user-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { addElement } from '../../../../assets/src/utils';

const activateUser = (userId, csrfToken) => {
fetch('index.php?action=ajax&ajax=user&ajaxaction=activate_user', {
fetch('./api/user/activate', {
method: 'POST',
headers: {
Accept: 'application/json, text/plain, */*',
Expand Down Expand Up @@ -53,7 +53,7 @@ const activateUser = (userId, csrfToken) => {

const deleteUser = (userId, csrfToken) => {
const message = document.getElementById('pmf-user-message');
fetch('index.php?action=ajax&ajax=user&ajaxaction=delete_user', {
fetch('./api/user/delete', {
method: 'DELETE',
headers: {
Accept: 'application/json, text/plain, */*',
Expand Down
Loading

0 comments on commit 93cddb2

Please sign in to comment.