216 lines
8.0 KiB
C#
216 lines
8.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
|
|
using NP.Model;
|
|
using System.Collections;
|
|
using NP.Base.Auth;
|
|
using NP.Base.ENUM;
|
|
|
|
namespace NP.Base.Controllers
|
|
{
|
|
/// <summary>
|
|
/// @custom@ : 본인인증처리 controller
|
|
/// </summary>
|
|
public partial class AOCommonController : NP.Base.BaseController
|
|
{
|
|
protected override void OnActionExecuting(ActionExecutingContext filterContext)
|
|
{
|
|
base.OnActionExecuting(filterContext);
|
|
}
|
|
protected override void OnException(ExceptionContext filterContext)
|
|
{
|
|
base.OnException(filterContext);
|
|
if (Request.IsAjaxRequest())
|
|
{
|
|
filterContext.Result = new RedirectResult("/Account/NoPermit?_code=" + NP.Base.ENUM.JSONCode.Error + "&_msg=알수없는오류");
|
|
}
|
|
else
|
|
{
|
|
filterContext.Result = new RedirectResult("/Account/Error?_code=" + NP.Base.ENUM.JSONCode.Error + "&_msg=알수없는오류");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// @custom@ : 인증문자발송처리
|
|
/// </summary>
|
|
/// <param name="mobile"></param>
|
|
/// <returns></returns>
|
|
// [HttpPost]
|
|
public JsonResult SendLakey(String mobile, String no)
|
|
{
|
|
long result = 0;
|
|
Random r = new Random();
|
|
int lakey = r.Next(100000, 999999);
|
|
//SmsAuth sa = new SmsAuth() { lakey = lakey.ToString(), userno=SUserInfo.UserNo };
|
|
SmsAuth sa = new SmsAuth() { lakey = lakey.ToString(), userno = long.Parse(no) };
|
|
String msg = "[영남건설기술교육원]\n\n영남건설기술교육원 인증번호 [" + lakey + "] 입니다.";
|
|
Dao.Insert("common.smsauth2", sa);
|
|
result = sa.authno;
|
|
|
|
IList<NP.Model.MemoUser> us = new List<NP.Model.MemoUser>();
|
|
us.Add(new MemoUser()
|
|
{
|
|
userno = SUserInfo.UserNo,
|
|
mobile = mobile,
|
|
title = "인증번호",
|
|
mcontents = msg,
|
|
smstype = "A",
|
|
isok = 1
|
|
});
|
|
SaveTalk(us, "alarm");
|
|
|
|
return JsonOK(result);
|
|
}
|
|
|
|
public string SendLakey2(String mobile, String no)
|
|
{
|
|
string result = "";
|
|
|
|
try
|
|
{
|
|
Random r = new Random();
|
|
int lakey = r.Next(100000, 999999);
|
|
//SmsAuth sa = new SmsAuth() { lakey = lakey.ToString(), userno=SUserInfo.UserNo };
|
|
SmsAuth sa = new SmsAuth() { lakey = lakey.ToString(), userno = long.Parse(no) };
|
|
String msg = "[영남건설기술교육원]\n\n영남건설기술교육원 인증번호 [" + lakey + "] 입니다.";
|
|
Dao.Insert("common.smsauth2", sa);
|
|
result = sa.authno.ToString();
|
|
|
|
IList<NP.Model.MemoUser> us = new List<NP.Model.MemoUser>();
|
|
us.Add(new MemoUser()
|
|
{
|
|
userno = SUserInfo.UserNo,
|
|
mobile = mobile,
|
|
title = "인증번호",
|
|
mcontents = msg,
|
|
smstype = "A",
|
|
isok = 1
|
|
});
|
|
SaveTalk(us, "alarm");
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
result = e.Message;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// @custom@ : 본인인증처리
|
|
/// </summary>
|
|
/// <param name="lakey"></param>
|
|
/// <param name="authno"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public JsonResult ChkLakey(String lakey, int authno)
|
|
{
|
|
IList<Data> datas = Dao.Get<Data>("common.sms.chk", new Hashtable() { { "authno", authno } });
|
|
if (datas.Count() < 1)
|
|
{
|
|
return JsonOK(0);
|
|
}
|
|
else if (datas.Where(w => w.strval.Replace(" ", "").Equals(lakey.Replace(" ", "")) && w.time.AddMinutes(3) < DateTime.Now).Count() > 0)
|
|
{
|
|
return JsonBack(new JsonRtn() { code = 1 });
|
|
}
|
|
else if (datas.Where(w => w.strval.Replace(" ", "").Equals(lakey.Replace(" ", "")) && w.time.AddMinutes(3) >= DateTime.Now).Count() > 0)
|
|
{
|
|
return JsonBack(new JsonRtn() { code = 1000, obj = datas.First() });
|
|
}
|
|
return JsonOK(0);
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult ExtendLakey(int authno)
|
|
{
|
|
return JsonOK(Dao.Save("common.sms.extend", new Hashtable() { { "authno", authno } }));
|
|
}
|
|
[HttpPost]
|
|
public JsonResult ViewCorrection(int sdno, int lectno)
|
|
{
|
|
var rtn = new Hashtable() { };
|
|
var sd = Dao.Get<LectSD>("lect.lectdiscuss", new Hashtable() { { "lectno", lectno }, { "sdno", sdno } }).FirstOrDefault();
|
|
rtn.Add("sd", sd);
|
|
return JsonBack(rtn);
|
|
}
|
|
[HttpPost]
|
|
public JsonResult CheckMobile(String mobile)
|
|
{
|
|
var checkuser = Dao.Get<int>("users.checkuser", new Hashtable() { { "mobile", mobile }, { "userid", null }, { "email", null } }).First();
|
|
if (checkuser < 9)
|
|
{
|
|
return JsonOK(0);
|
|
}
|
|
return JsonOK(1);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 본인인증검증 (before 인증문자발송)
|
|
/// </summary>
|
|
/// <param name="loginid"></param>
|
|
/// <param name="pw"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public JsonResult CheckLoginIp(string loginid, string pw)
|
|
{
|
|
string ip = GetUserIP();
|
|
var p = new Hashtable { { "userid", loginid }, { "password", NP.Base.Lib.KISA_SHA256.SHA256Hash(pw) }};
|
|
var ul = Dao.Get<Users>("users.adminlogin", p);
|
|
var u= new Users() { };
|
|
//해당 아이디인 계정이 없는 경우
|
|
if(ul.Count() < 1)
|
|
{
|
|
return JsonBack(new { code = -3 });
|
|
}
|
|
else
|
|
{
|
|
u = ul.FirstOrDefault();
|
|
|
|
// @custom@ : 로컬&nptech 자동로그인처리
|
|
bool isSkip = Helpers.IsSkipIPorHost(IpHostSkipGb.PassWord, ip, Request.ServerVariables["HTTP_HOST"]);
|
|
if (isSkip)
|
|
{
|
|
return JsonBack(new { code = 1 });
|
|
}
|
|
|
|
//비활성화 잠금
|
|
if (u.status == 9)
|
|
{
|
|
return JsonBack(new { code = -4 });
|
|
}
|
|
|
|
//비밀번호 불일치
|
|
if (u.userpass != NP.Base.Lib.KISA_SHA256.SHA256Hash(pw))
|
|
{
|
|
return JsonBack(new { code = -1 });
|
|
}
|
|
|
|
//210707 eduwreq 특정ip인증허용 정책 폐지
|
|
//if (ip.StartsWith("10.10.4.") || ip.StartsWith("10.10.13.") || ip == "192.168.103.13" || ip == "192.168.0.87" || ip == "121.140.58.113")
|
|
//return JsonBack(new JsonRtn() { code = 1});
|
|
//else
|
|
//{
|
|
//정보에 모바일번호 없는 경우
|
|
if (u != null && !string.IsNullOrEmpty(u.mobile))
|
|
{
|
|
return JsonBack(new { code = 1000, ip = ip, mobile = u.mobile, no = u.userno });
|
|
}
|
|
//기타에러
|
|
else
|
|
{
|
|
return JsonBack(new { code = -2 });
|
|
}
|
|
}
|
|
//}
|
|
}
|
|
[HttpPost]
|
|
public JsonResult DisableAccount(string loginid)
|
|
{
|
|
return JsonOK(Dao.Save("users.disable", new Hashtable() { { "userid", loginid } }));
|
|
}
|
|
}
|
|
}
|