示例#1
0
        /// <summary>
        /// Modify the user's information
        /// </summary>
        /// <param name="id">要修改的类型</param>
        /// <param name="newVal">the new value</param>
        /// <returns>修改结果的View</returns>
        public ActionResult Modify(string id, string newVal)
        {
            SolemartUser user = User as SolemartUser;

            switch (id)
            {
            case "UserName":
                user.SetUserName(newVal);
                break;

            case "Sex":
                int sex = int.Parse(newVal);
                user.SetSex((Sex)sex);
                break;

            case "Phone":
                user.SetPhone(newVal);
                break;

            case "Email":
                user.SetEmail(newVal);
                break;

            case "Address":
                user.SetAddress(newVal);
                break;
            }
            return(Content(WebResult <string> .SuccessResult.ResponseString));
        }
示例#2
0
        /// <summary>
        /// Login util for the user with id(used for weixin client).
        /// </summary>
        /// <param name="openID">The user's openID of weixin.</param>
        /// <remarks>
        ///
        /// </remarks>
        public static void WeixinLogin(string accessToken, string openID)
        {
            SolemartUser user = new SolemartUser(openID, LoginType.Weixin);

            if (string.IsNullOrEmpty(user.UserName))
            {
                OAuthUserInfo userInfo = OAuthApi.GetUserInfo(accessToken, openID);
                user.SetUserName(userInfo.nickname);
                user.SetHeadImage(userInfo.headimgurl);
            }

            Log.Instance.WriteLog(string.Format("AccountUtil::WeixinLogin userid[{0}], username[{1}]", user.UserID, user.UserName));
            //use Login to make user session.
            Login(user);
        }