Ejemplo n.º 1
0
 private string GetUserOperation( User user )
 {
     StringBuilder strBul = new StringBuilder();
     //if (BLLFactory<PermissionBLL>.Instance.HasActionPermission(UserContext.Instance.UserID, SysActions.用户_编辑)) {
         strBul.Append("<a href=\"/sysadmin/user/edit/" + user.UserID + "\">编辑</a>");
     //}
     //if (BLLFactory<PermissionBLL>.Instance.HasActionPermission(UserContext.Instance.UserID, SysActions.用户_停用)) {
         strBul.Append("<a href=\"/sysadmin/user/edit/" + user.UserID + "\">停用</a>");
     //}
     return strBul.ToString();
 }
Ejemplo n.º 2
0
 public void SinaCallback( )
 {
     var verifer = Request.QueryString["oauth_verifier"];
     if (verifer != null) {
         var reqToken = HttpContext.Session["RequestToken"] as OAuthRequestToken;
         var accessToken = AMicroblogAPI.AMicroblog.GetAccessToken(reqToken, verifer);
         HttpContext.Session["AccessToken"] = accessToken;
         AMicroblogAPI.Environment.AccessToken = accessToken;
         OpenAuth auth = openAuthService.GetOpenAuthEntityByOpenID(accessToken.UserID);
         if (auth != null) {
             if (auth.AccessTokenKey != accessToken.Token || auth.AccessTokenSecret != accessToken.Secret) {
                 auth.AccessTokenKey = accessToken.Token;
                 auth.AccessTokenSecret = accessToken.Secret;
                 openAuthService.UpdateOpenAuth(auth);
             }
             AccountState state = UserContext.Instance.OpenAuthLogin(accessToken.UserID, Utils.GetRealIP());
             switch (state) {
                 case AccountState.Normal: {
                         Response.Write("<script>opener.location.href=\"/\";window.close();</script>");
                         break;
                     }
                 //case AccountState.PendingActived: {
                 //        Model.Entities.User user = userService.GetUser(auth.UserID);
                 //        if (string.IsNullOrEmpty(user.Email)) {
                 //            Response.Write("<script>alert(\"尚未设置邮箱!\");opener.location.href=\"/site/updateemail\";window.close();</script>");
                 //        } else {
                 //            Response.Write("<script>alert(\"账户尚未激活!\");opener.location.href=\"/site/activeuser\";window.close();</script>");
                 //        }
                 //        break;
                 //    }
                 default: {
                         Response.Write("<script>opener.location.href =\"/site/login\";window.close();</script>");
                         break;
                     }
             }
         } else {
             AMicroblogAPI.DataContract.UserInfo userInfo = AMicroblogAPI.AMicroblog.GetUserInfo(Convert.ToInt64(accessToken.UserID));
             Codingwell.DevText.Model.Entities.User user = new Codingwell.DevText.Model.Entities.User();
             user.NickName = userInfo.ScreenName;
             user.Figureurl50 = userInfo.ProfileImageUrl;
             user.LastLoginTime = DateTime.Now;
             user.CreateTime = DateTime.Now;
             user.OpenAuthType = (int)OpenAuthType.Sinaweibo;
             user.AccountState = (int)AccountState.Normal;
             user.ActiveCode = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(Guid.NewGuid().ToString(), "md5");
             int userid = userService.CreateUser(user);
             HttpContext.Session["UserId"] = userid;
             auth = new OpenAuth();
             auth.OpenId = accessToken.UserID;
             auth.AccessTokenKey = accessToken.Token;
             auth.AccessTokenSecret = accessToken.Secret;
             auth.UserID = userid;
             auth.InsertTime = DateTime.Now;
             openAuthService.CreateOpenAuth(auth);
             UserContext.Instance.OpenAuthLogin(accessToken.UserID, Utils.GetRealIP());
             Response.Write("<script>opener.location.href=opener.location.href;window.close();</script>");
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 创建用户
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public int CreateUser( User user )
 {
     try {
         userRepository.Add(user);
         Save();
         return user.UserID;
     } catch (Exception ex) {
         //log.Error(ex.Message, ex);
         return -1;
     }
 }
Ejemplo n.º 4
0
 public bool UpdateUser( User user )
 {
     try {
         userRepository.Update(user);
         Save();
         return true;
     } catch (Exception ex) {
         //log.Error(ex.Message, ex);
         return false;
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 更新登录信息
 /// </summary>
 /// <param name="user"></param>
 public void UpdateLastLoginInfo( User user )
 {
     userRepository.Update(user);
     Save();
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 发送激活邮件
 /// </summary>
 /// <param name="user"></param>
 public void SendActiveEmail( User user )
 {
     string subject = "Devtext 注册激活邮件";
     StringBuilder strBul = new StringBuilder();
     strBul.Append("<html><head><title>Devtext 注册激活邮件</title></head>");
     strBul.Append("<body>");
     strBul.Append("<b>亲爱的" + user.NickName + ": </b>");
     strBul.Append("<p>感谢您注册Devtext.com,为了防止机器人注册、让您更好更安全地使用我们的网站,需要您激活您的账号,确认您邮箱的可用性。</p>");
     strBul.Append("<p>激活码:" + user.ActiveCode + "</p>");
     strBul.Append("<p>激活路径:<a href=\"http://www.devtext.com/site/activeuser\">http://www.devtext.com/site/activeuser</a></p>");
     strBul.Append("<p>再次感谢您的支持,谢谢。</p>");
     strBul.Append("<p>备注:本邮件由系统自动发出,请勿直接回复邮件,谢谢。</p>");
     strBul.Append("</body>");
     strBul.Append("</html>");
     MailService.SendMail(subject, strBul.ToString(), user.Email, string.Empty, string.Empty);
 }