예제 #1
0
        /// <summary>
        /// Calls service for registering a new user
        /// </summary>
        /// <param name="email"></param>
        /// <param name="password"></param>
        /// <param name="passwordKey"></param>
        /// <param name="callback"></param>
        public void Register(User newUser, string passwordKey, string facebookAuthCode, Action<bool> callback)
        {
            Service.Invoke("Register",
                response =>
                {
                    if (response.Error != null)
                        MessageBox.Show(response.Error.Message, "MediaVF", MessageBoxButton.OK);

                    callback(response.Error == null);
                },
                newUser,
                passwordKey,
                facebookAuthCode);
        }
예제 #2
0
        /// <summary>
        /// Registers a new user using the given password key to decrypt their password
        /// </summary>
        /// <param name="newUser"></param>
        /// <param name="passwordKey"></param>
        public void Register(User newUser, string passwordKey, string facebookAuthCode)
        {
            // check if user already exists
            List<User> allUsers = DataManager.GetDataContext<User>().GetAll<User>();
            if (allUsers.Any(u => u.UserName == newUser.UserName))
                throw new Exception(USER_EXISTS);

            if (newUser.SyncWithFacebook)
                newUser.FacebookAccessToken = FacebookManager.GetFacebookAccessToken(facebookAuthCode);

            // decrypt password
            string decrypted = EncryptionUtility.Decrypt(passwordKey, newUser.Password);

            // re-encrypt password with server key

            string serverEncrypt = EncryptionUtility.Encrypt(ServerPasswordKey, decrypted);

            // set the user's password to the server-encrypted version
            newUser.Password = serverEncrypt;

            // add the users to the data context and save
            DataManager.GetDataContext<User>().AddObjects<User>(new User[] { newUser }.ToList());
            DataManager.GetDataContext<User>().Save();

            // add the user the logged on users
            if (!LoggedOnUsers.Any(u => u.Email == newUser.Email))
                LoggedOnUsers.Add(newUser);
        }
예제 #3
0
 /// <summary>
 /// Create a new User object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="userName">Initial value of the UserName property.</param>
 /// <param name="password">Initial value of the Password property.</param>
 /// <param name="email">Initial value of the Email property.</param>
 /// <param name="syncWithFacebook">Initial value of the SyncWithFacebook property.</param>
 /// <param name="created">Initial value of the Created property.</param>
 /// <param name="modified">Initial value of the Modified property.</param>
 public static User CreateUser(global::System.Int32 id, global::System.String userName, global::System.String password, global::System.String email, global::System.Boolean syncWithFacebook, global::System.DateTime created, global::System.DateTime modified)
 {
     User user = new User();
     user.ID = id;
     user.UserName = userName;
     user.Password = password;
     user.Email = email;
     user.SyncWithFacebook = syncWithFacebook;
     user.Created = created;
     user.Modified = modified;
     return user;
 }
예제 #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUsers(User user)
 {
     base.AddObject("Users", user);
 }
예제 #5
0
        public void Login()
        {
            IsBusy = true;
            BusyMessage = "Logging in...";

            if (StoreCredentials)
            {
                AdminModule adminModule = Container.Resolve<AdminModule>();
                if (adminModule != null)
                {
                    adminModule.Email = Email;
                    adminModule.Password = Password;
                }
            }

            /*
            AdminServiceClient userServiceClient = Container.Resolve<AdminServiceClient>();
            userServiceClient.Login(Email, Password, LoginKey,
                (result) =>
                {*/
                    IsBusy = false;

                    /*if (result != null)
                    {*/
                        CurrentUser = new User() { UserName = "******" }; //result;
                        LogInRequired = false;
                    /*}
                });
             */
        }