mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 18:03:27 +08:00
【优化】优化未注册情况下,用户请求接口无权限返回提示,而可能存在loading层,导致无法操作的问题。
This commit is contained in:
@@ -1,56 +0,0 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace CoreCms.Net.Auth.Policys
|
||||
{
|
||||
public class ApiResponse
|
||||
{
|
||||
public int Status { get; set; } = 404;
|
||||
public object Value { get; set; } = "No Found";
|
||||
|
||||
public ApiResponse(StatusCode apiCode, object msg = null)
|
||||
{
|
||||
switch (apiCode)
|
||||
{
|
||||
case StatusCode.CODE401:
|
||||
{
|
||||
Status = 401;
|
||||
Value = "很抱歉,您无权访问该接口,请确保已经登录!";
|
||||
}
|
||||
break;
|
||||
case StatusCode.CODE403:
|
||||
{
|
||||
Status = 403;
|
||||
Value = "很抱歉,您的访问权限等级不够,联系管理员!";
|
||||
}
|
||||
break;
|
||||
case StatusCode.CODE500:
|
||||
{
|
||||
Status = 500;
|
||||
Value = msg;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum StatusCode
|
||||
{
|
||||
CODE401,
|
||||
CODE403,
|
||||
CODE404,
|
||||
CODE500
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ namespace CoreCms.Net.Auth.Policys
|
||||
protected override async Task HandleChallengeAsync(AuthenticationProperties properties)
|
||||
{
|
||||
Response.ContentType = "application/json";
|
||||
//Response.StatusCode = StatusCodes.Status401Unauthorized;
|
||||
Response.StatusCode = StatusCodes.Status401Unauthorized;
|
||||
//await Response.WriteAsync(JsonConvert.SerializeObject(new ApiResponse(StatusCode.CODE401)));
|
||||
|
||||
var jm = new WebApiCallBack();
|
||||
@@ -49,7 +49,7 @@ namespace CoreCms.Net.Auth.Policys
|
||||
protected override async Task HandleForbiddenAsync(AuthenticationProperties properties)
|
||||
{
|
||||
Response.ContentType = "application/json";
|
||||
//Response.StatusCode = StatusCodes.Status403Forbidden;
|
||||
Response.StatusCode = StatusCodes.Status403Forbidden;
|
||||
//await Response.WriteAsync(JsonConvert.SerializeObject(new ApiResponse(StatusCode.CODE403)));
|
||||
|
||||
var jm = new WebApiCallBack();
|
||||
|
||||
Reference in New Issue
Block a user