瀏覽代碼

[Authentication] Added more logs for token validation error

develop
Robin Thoni 9 年之前
父節點
當前提交
99a183d7a7
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. 7
    0
      Authentication/Business/JWT/TokenValidationHandler.cs

+ 7
- 0
Authentication/Business/JWT/TokenValidationHandler.cs 查看文件

@@ -89,12 +89,19 @@ namespace iiie.Authentication.Business.JWT
89 89
                 var salt = ((ClaimsIdentity)claim.Identity).Claims.FirstOrDefault(x => x.Type == ClaimTypes.Authentication);
90 90
 
91 91
                 if (name == null || salt == null)
92
+                {
93
+                    OpResult<bool>.Error(ResultStatus.LoginError, string.Format("Incomplete token; username is present: {0}; salt is present {1}", name != null, salt != null)).Log();
92 94
                     statusCode = HttpStatusCode.Unauthorized;
95
+                }
93 96
                 else
94 97
                 {
95 98
                     var user = GetUserDbo(name.Value, salt.Value);
96 99
                     if (user == null)
100
+                    {
101
+                        OpResult<bool>.Error(ResultStatus.LoginError,
102
+                            string.Format("Username {0} not found", name.Value)).Log();
97 103
                         statusCode = HttpStatusCode.Unauthorized;
104
+                    }
98 105
                     else
99 106
                     {
100 107
                         UserStorage.BasicUserDbo = user;

Loading…
取消
儲存