Exemplo n.º 1
0
        public async Task GoNextAboutStep(UserWrapper user)
        {
            if (user.LastCallBackQuery == null)
            {
                return;
            }

            var propName = user.LastCallBackQuery.Data.Replace(InlinePrefixKeys.AboutKey + "Edit", "");

            if (user.WaitingMessageQuery == null || user.WaitingMessageQuery != nameof(GoNextAboutStep))
            {
                user.WaitingMessageQuery = nameof(GoNextAboutStep);
                await Bot.EditMessageReplyMarkupAsync(user.LastCallBackQuery.Message.Chat.Id,
                                                      user.LastCallBackQuery.Message.MessageId, KeyboardCollection.CancelInlineKeyboard());

                await AnswerCallbackQueryAsync(user, $"Please enter new {Localization.ResourceManager.GetString(propName)?.ToLower()} and press Enter key.", false, cacheTime : 6000);
            }
            else
            {
                var prop = WebsiteManager.GetType().GetProperties().FirstOrDefault(p => p.Name == propName);
                prop?.SetValue(WebsiteManager, user.LastMessageQuery.Text);
                await Bot.EditMessageTextAsync(user.LastCallBackQuery.Message.Chat.Id, user.LastCallBackQuery.Message.MessageId,
                                               Localization.ResourceManager.GetString(propName) + ": \n\r" + (prop?.GetValue(WebsiteManager) ?? "---"),
                                               ParseMode.Default, false, (IReplyMarkup)KeyboardCollection.GetType().GetProperties().FirstOrDefault(p => p.Name.StartsWith(propName))?.GetValue(KeyboardCollection));

                user.WaitingMessageQuery = null; // waiting method called and then clear buffer
            }
        }
Exemplo n.º 2
0
        public async Task GoNextLogoStep(UserWrapper user)
        {
            if (user.LastCallBackQuery == null)
            {
                return;
            }

            if (user.WaitingMessageQuery == null || user.WaitingMessageQuery != nameof(GoNextLogoStep))
            {
                user.WaitingMessageQuery = nameof(GoNextLogoStep);
                await Bot.EditMessageReplyMarkupAsync(user.LastCallBackQuery.Message.Chat.Id,
                                                      user.LastCallBackQuery.Message.MessageId, KeyboardCollection.CancelInlineKeyboard());

                await AnswerCallbackQueryAsync(user, "Please send an image to change logo ...", false, cacheTime : 6000);
            }
            else if (user.LastMessageQuery.Photo.Any())
            {
                using (var mem = new MemoryStream())
                {
                    await Bot.GetFileAsync(user.LastMessageQuery.Photo.Last().FileId, mem);

                    WebsiteManager.Logo = mem.ToByte();
                    await DeleteMessageAsync(user.LastCallBackQuery.Message);

                    await Bot.SendTextMessageAsync(user.LastCallBackQuery.Message.Chat.Id, "The logo changed successfully.");
                }
                user.WaitingMessageQuery = null; // waiting method called and then clear buffer
            }
            else
            {
                await AnswerCallbackQueryAsync(user, "Please send an image to change logo ...", false, cacheTime : 6000);
            }
        }
Exemplo n.º 3
0
 public bool AddInstantly(UserWrapper user, string achievementId)
 {
     if (AllowedAchievements.ContainsKey(achievementId))
     {
         var            achievement   = AllowedAchievements[achievementId];
         DB.Achievement dbAchievement = DB.Achievement.FindUserAchievement(user.Id, achievementId);
         if (dbAchievement == null)
         {
             dbAchievement               = new DB.Achievement();
             dbAchievement.UserId        = user.Id;
             dbAchievement.AchievementId = achievementId;
             dbAchievement.AchievedAt    = DateTime.Now;
             var result = dbAchievement.Save();
             if (result)
             {
                 var messageBuilder  = Game.messageBuilder;
                 var message         = messageBuilder.GetText("AchievementUnlocked");
                 var achievementText = $"<b>{achievement.Icon} {achievement.Name}</b>";
                 var replaces        = new Dictionary <string, object> {
                     { "name", messageBuilder.FormatName(user) }, { "achievement", achievementText }
                 };
                 messageBuilder
                 .Text(messageBuilder.Format(message, replaces), false)
                 .SendPublic(Game.gameChannel);
             }
             return(result);
         }
     }
     return(false);
 }
        private void InitializetUser(User user)
        {
            User = new UserWrapper(user);
            User.PropertyChanged += (s, e) =>
            {
                if (!HasChanges)
                {
                    HasChanges = _userRepository.HasChanges();
                }

                if (e.PropertyName == nameof(User.HasErrors))
                {
                    ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged();
                 }
                if (e.PropertyName == nameof(User.FirstName)
                  || e.PropertyName == nameof(User.LastName))
                {
                    SetTitle();
                }
            };
            ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged();
  
            if (User.Id == 0)
            {
                // Little trick to trigger the validation
                User.FirstName = "";
                User.LastName = "";
                User.UserName = "";
                User.CreatedDate = DateTime.Now;
                User.SessionTimeOut = 1;
            }
            SetTitle();
        }
Exemplo n.º 5
0
        public IActionResult Users()
        {
            if (!CheckLoggedIn())
            {
                return(RedirectToAction("Index", "Home"));
            }
            int?              id          = HttpContext.Session.GetInt32("LOGGED_IN_USER");
            List <User>       AllUsers    = _context.Users.Include(c => c.friends).Where(u => u.userid != (int)id).ToList();
            List <Friendship> Connections = _context.Friends.Where(c => c.userid == (int)id).ToList();
            List <User>       Updated     = new List <User>();

            foreach (var user in AllUsers)
            {
                var connections = Connections as List <Friendship>;
                if (connections.Any(c => c.friendid == user.userid))
                {
                    Console.WriteLine("Pass");
                }
                else
                {
                    Updated.Add(user);
                }
            }
            ViewBag.Connections = Connections;
            UserWrapper model = new UserWrapper(Updated, Connections);

            return(View(model));
        }
Exemplo n.º 6
0
        public IActionResult ChangeContact(UserWrapper WrappedContact)
        {
            int?    LoggedInUserID = HttpContext.Session.GetInt32("LoggedInUserID");
            Contact ContactToEdit  = dbContext.Contacts.Include(c => c.Company).FirstOrDefault(c => c.ContactId == WrappedContact.CurrentContact.ContactId);

            ContactToEdit.Name            = WrappedContact.CurrentContact.Name;
            ContactToEdit.PhoneNumber     = WrappedContact.CurrentContact.PhoneNumber;
            ContactToEdit.Email           = WrappedContact.CurrentContact.Email;
            ContactToEdit.Notes           = WrappedContact.CurrentContact.Notes;
            WrappedContact.CurrentContact = ContactToEdit;
            if (LoggedInUserID == null)
            {
                return(RedirectToAction("Index"));
            }
            if (WrappedContact.CurrentContact.Company.UserId != (int)LoggedInUserID)
            {
                return(RedirectToAction("Dashboard"));
            }
            if (ModelState.IsValid)
            {
                dbContext.Contacts.Update(ContactToEdit);
                dbContext.SaveChanges();
                return(Redirect($"company/{ContactToEdit.Company.CompanyId}"));
            }
            return(EditContact(WrappedContact.CurrentContact.ContactId));
        }
Exemplo n.º 7
0
        public IActionResult LoggedIn()
        {
            int?LoggedInUserID = HttpContext.Session.GetInt32("LoggedInUserID");

            if (LoggedInUserID == null)
            {
                return(RedirectToAction("Index"));
            }
            UserWrapper MyUser = new UserWrapper();

            MyUser.CurrentUser = (User)dbContext.Users
                                 .FirstOrDefault(user => user.UserId == LoggedInUserID);
            List <Transaction> UserTransactions = dbContext.Transactions
                                                  .Where(u => u.UserId == (int)LoggedInUserID)
                                                  .OrderByDescending(t => t.CreatedAt)
                                                  .ToList();

            MyUser.CurrentUser.TransactionHistory = UserTransactions;
            int UserBalance = 0;

            foreach (Transaction transaction in MyUser.CurrentUser.TransactionHistory)
            {
                UserBalance += (int)transaction.Amount;
            }
            MyUser.Balance = UserBalance;
            return(View(MyUser));
        }
Exemplo n.º 8
0
        public IActionResult Transaction(UserWrapper WrappedTransaction)
        {
            Transaction NewTransaction = WrappedTransaction.NewTransaction;
            int?        LoggedInUserID = HttpContext.Session.GetInt32("LoggedInUserID");

            NewTransaction.UserId          = (int)LoggedInUserID;
            WrappedTransaction.CurrentUser = (User)dbContext.Users.FirstOrDefault(user => user.UserId == LoggedInUserID);
            List <Transaction> UserTransactions = dbContext.Transactions
                                                  .Where(u => u.UserId == (int)LoggedInUserID)
                                                  .OrderByDescending(t => t.CreatedAt)
                                                  .ToList();

            WrappedTransaction.CurrentUser.TransactionHistory = UserTransactions;
            int UserBalance = 0;

            foreach (Transaction transaction in WrappedTransaction.CurrentUser.TransactionHistory)
            {
                UserBalance += (int)transaction.Amount;
            }
            WrappedTransaction.Balance = UserBalance;
            if (UserBalance + NewTransaction.Amount < 0)
            {
                ModelState.AddModelError("NewTransaction.Amount", "Insufficient Funds");
            }
            if (ModelState.IsValid)
            {
                dbContext.Add(NewTransaction);
                dbContext.SaveChanges();
                return(RedirectToAction("LoggedIn"));
            }

            return(View("LoggedIn", WrappedTransaction));
        }
Exemplo n.º 9
0
        private void Initialize(User user)
        {
            if (user == null)
            {
                return;
            }

            User = new UserWrapper(user);

            User.PropertyChanged += ((sender, args) =>
            {
                if (!HasChanges)
                {
                    HasChanges = _userRepository.HasChanges();
                }

                if (args.PropertyName == nameof(User.HasErrors))
                {
                    SaveCommand.RaiseCanExecuteChanged();
                }
            });

            SaveCommand.RaiseCanExecuteChanged();

            if (User.Id == Guid.Empty)
            {
                User.Login = "";
            }
        }
        private async Task AnnounceToggle(bool value)
        {
            var user = new UserWrapper(Context.User);

            using (var context = new GameContext())
            {
                var dbUser = context.Users.SingleOrDefault(u => u.Id == user.Id);
                if (dbUser == null)
                {
                    dbUser = new User {
                        Id = user.Id
                    };
                }

                try
                {
                    dbUser.IsNotificationEnabled = value;
                    context.SaveChanges();
                    await ReplyAsync(_game.MessageBuilder.GetTextSimple("PersonalSettingsChangeSuccess"));
                }
                catch (Exception ex)
                {
                    await ReplyAsync(_game.MessageBuilder.GetTextSimple("PersonalSettingsChangeFail", new Dictionary <string, object> {
                        ["message"] = ex.Message
                    }));
                }
            }
        }
Exemplo n.º 11
0
        protected override int RawRead(byte[] buffer, int offset, int count)
        {
            // stream_read:
            var result = UserWrapper.InvokeWrapperMethod(USERSTREAM_READ, (PhpValue)count);

            if (result.IsEmpty == false)
            {
                var bytes     = result.ToBytes(RuntimeContext);
                int readbytes = bytes.Length;
                if (readbytes > count)
                {
                    //php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_READ " - read %ld bytes more data than requested (%ld read, %ld max) - excess data will be lost",
                    //    us->wrapper->classname, (long)(didread - count), (long)didread, (long)count);
                    readbytes = count;
                }

                if (readbytes > 0)
                {
                    Array.Copy(bytes, 0, buffer, offset, readbytes);
                }

                return(readbytes);
            }

            //
            return(0);
        }
Exemplo n.º 12
0
    private IEnumerator searchFriend()
    {
        MessageController.single.displayWaitScreen(_friendSearchCanvas);
        UserWrapper wrapper = new UserWrapper();

        yield return(SpatialClient2.single.GetUserByUsername(wrapper, _friendSearchBox.text));

        if (wrapper.User != null)
        {
            _userSearchResult = wrapper.User;
            if (SpatialClient2.single.alreadyFriend(_userSearchResult.Id))
            {
                _userFoundText.text    = YOU_ARE_ALREADY_FRIENDS_WITH + _userSearchResult.getName() + '.';
                _userFoundText.enabled = true;
            }
            else
            {
                //_userFoundText.text = ADD + _userSearchResult.getName() + AS_FRIEND;
                //_addFriendButton.enabled = true;

                onAddFriend();
            }
            //_userFoundText.enabled = true;
        }
        else
        {
            _userNotFoundText.enabled = true;
        }
        MessageController.single.closeWaitScreen(false);
    }
Exemplo n.º 13
0
 public IList <DB.Achievement> GetAchievements(UserWrapper user)
 {
     using (var gameContext = new GameContext())
     {
         return(gameContext.Achievements.AsNoTracking().Where(u => u.UserId == user.Id).ToList());
     }
 }
Exemplo n.º 14
0
        public IActionResult ChangeCompany(UserWrapper WrappedCompany)
        {
            int?    LoggedInUserID = HttpContext.Session.GetInt32("LoggedInUserID");
            Company CompanyToEdit  = dbContext.Companies.FirstOrDefault(c => c.CompanyId == WrappedCompany.CurrentCompany.CompanyId);

            CompanyToEdit.Name            = WrappedCompany.CurrentCompany.Name;
            CompanyToEdit.Description     = WrappedCompany.CurrentCompany.Description;
            CompanyToEdit.Notes           = WrappedCompany.CurrentCompany.Notes;
            WrappedCompany.CurrentCompany = CompanyToEdit;
            if (LoggedInUserID == null)
            {
                return(RedirectToAction("Index"));
            }
            if (WrappedCompany.CurrentCompany.UserId != (int)LoggedInUserID)
            {
                return(RedirectToAction("Dashboard"));
            }
            if (ModelState.IsValid)
            {
                dbContext.Companies.Update(CompanyToEdit);
                dbContext.SaveChanges();
                return(Redirect($"company/{CompanyToEdit.CompanyId}"));
            }
            return(EditCompany(WrappedCompany.CurrentCompany.CompanyId));
        }
Exemplo n.º 15
0
        public IActionResult CreateInterview(UserWrapper WrappedInterview)
        {
            int?LoggedInUserID = HttpContext.Session.GetInt32("LoggedInUserID");

            if (LoggedInUserID == null)
            {
                return(RedirectToAction("Index"));
            }
            Position CurrentPosition = dbContext.Positions.Include(c => c.Company).FirstOrDefault(p => p.PositionId == WrappedInterview.CurrentInterview.PositionId);

            if (CurrentPosition == null || CurrentPosition.Company.UserId != (int)LoggedInUserID)
            {
                return(RedirectToAction("Dashboard"));
            }
            if (DateTime.Now.CompareTo(WrappedInterview.CurrentInterview.Date) > 0)
            {
                ModelState.AddModelError("CurrentInterview.Date", "Please enter a time in the future");
            }
            if (ModelState.IsValid)
            {
                dbContext.Interviews.Add(WrappedInterview.CurrentInterview);
                dbContext.SaveChanges();
                return(Redirect($"position/{CurrentPosition.PositionId}"));
            }
            return(NewInterview(CurrentPosition.PositionId));
        }
Exemplo n.º 16
0
        protected override int RawWrite(byte[] buffer, int offset, int count)
        {
            PhpValue bytes;

            if (count == 0)
            {
                bytes = PhpValue.Create(string.Empty);
            }
            if (offset == 0 && count == buffer.Length)
            {
                bytes = PhpValue.Create(new PhpString(buffer));
            }
            else
            {
                var data = new byte[count];
                Array.Copy(buffer, offset, data, 0, count);
                bytes = PhpValue.Create(new PhpString(data));
            }

            var result = UserWrapper.InvokeWrapperMethod(USERSTREAM_WRITE, bytes);

            var byteswrote = result.ToLong();

            if (byteswrote > count)
            {
                //php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s::" USERSTREAM_WRITE " wrote %ld bytes more data than requested (%ld written, %ld max)",
                //us->wrapper->classname, (long)(didwrite - count), (long)didwrite, (long)count);
                byteswrote = count;
            }

            return((int)byteswrote);
        }
Exemplo n.º 17
0
        public IActionResult ChangePosition(UserWrapper WrappedPosition)
        {
            int?     LoggedInUserID = HttpContext.Session.GetInt32("LoggedInUserID");
            Position PositionToEdit = dbContext.Positions.Include(c => c.Company).FirstOrDefault(p => p.PositionId == WrappedPosition.CurrentPosition.PositionId);

            PositionToEdit.Name             = WrappedPosition.CurrentPosition.Name;
            PositionToEdit.Description      = WrappedPosition.CurrentPosition.Description;
            PositionToEdit.Requirements     = WrappedPosition.CurrentPosition.Requirements;
            PositionToEdit.Link             = WrappedPosition.CurrentPosition.Link;
            PositionToEdit.Notes            = WrappedPosition.CurrentPosition.Notes;
            WrappedPosition.CurrentPosition = PositionToEdit;
            if (LoggedInUserID == null)
            {
                return(RedirectToAction("Index"));
            }
            if (WrappedPosition.CurrentPosition.Company.UserId != (int)LoggedInUserID)
            {
                return(RedirectToAction("Dashboard"));
            }
            if (ModelState.IsValid)
            {
                dbContext.Positions.Update(PositionToEdit);
                dbContext.SaveChanges();
                return(Redirect($"position/{PositionToEdit.PositionId}"));
            }
            return(EditPosition(WrappedPosition.CurrentPosition.PositionId));
        }
Exemplo n.º 18
0
        public IActionResult ChangeInterview(UserWrapper WrappedInterview)
        {
            int?      LoggedInUserID  = HttpContext.Session.GetInt32("LoggedInUserID");
            Interview InterviewToEdit = dbContext.Interviews.Include(p => p.Position).ThenInclude(c => c.Company).FirstOrDefault(i => i.InterviewId == WrappedInterview.CurrentInterview.InterviewId);

            InterviewToEdit.Date              = WrappedInterview.CurrentInterview.Date;
            InterviewToEdit.Notes             = WrappedInterview.CurrentInterview.Notes;
            WrappedInterview.CurrentInterview = InterviewToEdit;
            if (LoggedInUserID == null)
            {
                return(RedirectToAction("Index"));
            }
            if (WrappedInterview.CurrentInterview.Position.Company.UserId != (int)LoggedInUserID)
            {
                return(RedirectToAction("Dashboard"));
            }
            if (DateTime.Now.CompareTo(WrappedInterview.CurrentInterview.Date) > 0)
            {
                ModelState.AddModelError("CurrentInterview.Date", "Please enter a time in the future");
            }
            if (ModelState.IsValid)
            {
                dbContext.Interviews.Update(InterviewToEdit);
                dbContext.SaveChanges();
                return(Redirect($"position/{InterviewToEdit.Position.PositionId}"));
            }
            return(EditInterview(WrappedInterview.CurrentInterview.InterviewId));
        }
Exemplo n.º 19
0
        public IActionResult LoginUser(Login newLogin)
        {
            UserWrapper Wrapper = new UserWrapper();

            Wrapper.NewLogin = newLogin;
            if (ModelState.IsValid)
            {
                var userInDb = dbContext.Users.FirstOrDefault(u => u.Email == newLogin.LoginEmail);
                if (userInDb == null)
                {
                    ModelState.AddModelError("NewLogin.LoginEmail", "User with such email does not exist");
                    return(View("Index", Wrapper));
                }
                var hasher = new PasswordHasher <Login>();
                var result = hasher.VerifyHashedPassword(newLogin, userInDb.Password, newLogin.LoginPassword);
                if (result == 0)
                {
                    ModelState.AddModelError("NewLogin.LoginPassword", "Invalid Password");
                    return(View("Index", Wrapper));
                }
                HttpContext.Session.SetInt32("UserId", userInDb.UserId);
                int?temp = HttpContext.Session.GetInt32("UserId");
                Console.WriteLine("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
                Console.WriteLine(temp);
                ViewBag.UserId = HttpContext.Session.GetInt32("UserId");
                Console.Write("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
                return(RedirectToAction("Dashboard"));
            }
            return(View("Index"));
        }
Exemplo n.º 20
0
 private void OnUpdateUserExecute(UserWrapper user)
 {
     if (user == null)
     {
         return;
     }
     _userDetailViewModel.Open(user.Model, _roles);
 }
Exemplo n.º 21
0
 public async Task AnswerCallbackQueryAsync(UserWrapper user, string text = null, bool showAlert = false, string url = null, int cacheTime = 0)
 {
     if (CanAnswerCallBack(user))
     {
         user.LastRequestElapsedTime?.Stop();
         await Bot.AnswerCallbackQueryAsync(user.LastCallBackQuery?.Id, text, showAlert, url, cacheTime);
     }
 }
Exemplo n.º 22
0
 static void initWrappers()
 {
     // Initialize the wrappers used for this sample.
     ctx = ws.getContextWrapper();
     crs = ws.getCourseWrapper();
     crm = ws.getCourseMembershipWrapper();
     usr = ws.getUserWrapper();
 }
Exemplo n.º 23
0
 protected IDMChannel GetPrivateChannel(UserWrapper user)
 {
     if (!PrivateChannels.ContainsKey(user.Id))
     {
         PrivateChannels.Add(user.Id, user.GetDmChannel());
     }
     return(PrivateChannels[user.Id]);
 }
Exemplo n.º 24
0
 public bool Push(UserWrapper user, string achievementId)
 {
     if (AllowedAchievements.ContainsKey(achievementId))
     {
         Achievements.Add(new Tuple <UserWrapper, Achievement>(user, AllowedAchievements[achievementId]));
         return(true);
     }
     return(false);
 }
Exemplo n.º 25
0
 public SellTransactionViewModel(FilterViewModel filter, UserWrapper user, UserAuthenticationWrapper authenticationUser)
 {
     _authenticationUser = authenticationUser;
     _user         = user;
     _filter       = filter;
     Offers        = new BindableCollection <SellOfferWrapper>();
     SelectedOffer = new SellOfferWrapper(new sell_Offer());
     AcceptCommand = new AsyncRelayCommand(execute => Accept(), canExecute => { return(true); });
 }
Exemplo n.º 26
0
        // This handles the login logic
        private dynamic login(Login user)
        {
            // Get the Session variables for caller method
            string caller = HttpContext.Session.GetString("login_route");

            // Check model validations
            if (ModelState.IsValid)
            {
                // All validations are good. Let's check if user exists
                User dbuser = _context.Users.Where(item => item.Email == user.Email_field).SingleOrDefault();
                // If the user exists we do our checks
                if (dbuser != null)
                {
                    // User exists. Let's check password
                    if (dbuser.check_password(user.Password_field))
                    {
                        // Set the session variables
                        HttpContext.Session.SetString("authenticated", "Yes");
                        HttpContext.Session.SetInt32("user", dbuser.Id);
                        // Get the Session variables for Return URL if they exist
                        string route      = HttpContext.Session.GetString("source_action");
                        string controller = HttpContext.Session.GetString("source_controller");
                        int?   id         = HttpContext.Session.GetInt32("source_id");
                        // Remove the existing Session keys for the Return URL
                        HttpContext.Session.Remove("source_controller");
                        HttpContext.Session.Remove("source_action");
                        // Set the ID if it is present
                        if (id != null)
                        {
                            HttpContext.Session.Remove("source_id");
                        }
                        // Set the default action and controller for redirect
                        if (route == null && controller == null)
                        {
                            route      = "Index";
                            controller = "Song";
                        }
                        //Password is good. Redirect to route and controller specified
                        return(RedirectToAction(route, controller, new { id = id }));
                    }
                }
                else
                {
                    ModelState.AddModelError("Email_field", "This email does not exist");
                }
            }
            // This was the short hand login View
            if (caller == "Login")
            {
                return(View(user));
            }
            // This is the Index page if no other caller was set
            UserWrapper wrapper = new UserWrapper(new User(), user);

            return(View("Index", wrapper));
        }
Exemplo n.º 27
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public UserController()
        {
            AuthBuilder authBuilder = AuthBuilder.GetInstance();

            this.IUserMgr = authBuilder.GetManager <IUserMgr>(AuthBuilder.IUSERMGR);

            this.UserWrapper = UserWrapper.GetInstance();

            this.SystemLogWrapper = SystemLogWrapper.GetInstance();
        }
Exemplo n.º 28
0
        public static StringContent Serialize(user u)
        {
            string temp = JsonConvert.SerializeObject(UserWrapper.Wrap(u),
                                                      new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            StringContent str = new StringContent(temp, Encoding.UTF8, "application/json");

            return(str);
        }
Exemplo n.º 29
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public AuthWorker()
        {
            // Wrapper creation
            this.UserWrapper = UserWrapper.GetInstance();
            // CRM Creation
            AuthBuilder crmBuilder = AuthBuilder.GetInstance();

            this.ITokenTrackingMgr = crmBuilder.GetManager <ITokenTrackingMgr>(AuthBuilder.ITOKENTRACKINGMGR);
            this.IUserMgr          = crmBuilder.GetManager <IUserMgr>(AuthBuilder.IUSERMGR);
        }
Exemplo n.º 30
0
        public bool UserAuthenticated(User user, out UserWrapper userWrapper)
        {
            if (!Accounts.ContainsKey(user.Id))
            {
                Accounts[user.Id] = UserWrapper.Factory(user);
            }

            userWrapper = Accounts[user.Id];

            return(Accounts[user.Id].IsAuthenticated);
        }
Exemplo n.º 31
0
 internal bool UserEquals(UserWrapper user, IIdentity identity)
 {
     return String.Equals(user.Username, identity.Name, StringComparison.Ordinal);
 }
Exemplo n.º 32
0
 internal User(UserWrapper user)
 {
     this.Wrapper = user;
 }
Exemplo n.º 33
0
 static MembershipUser CreateMembershipUser(string providerName, UserWrapper user)
 {
     return new MembershipUser(
     providerName: providerName,
     name: user.Username,
     providerUserKey: user.Id,
     email: user.Email,
     passwordQuestion: null,
     comment: null,
     isApproved: true,
     isLockedOut: !user.Disabled,
     creationDate: default(DateTime),
     lastLoginDate: user.LastSignIn.GetValueOrDefault(),
     lastActivityDate: default(DateTime),
     lastPasswordChangedDate: default(DateTime),
     lastLockoutDate: default(DateTime)
      );
 }