Esempio n. 1
0
 private async Task SignInAsync(AbpUser user, bool isPersistent)
 {
     AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
     var identity = await _userManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
     identity.AddClaim(new Claim(AbpClaimTypes.TenantId, "42"));
     AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = isPersistent }, identity);
 }
 public bool HasFriendship(AbpUser user, AbpUser probableFriend)
 {
     return(_friendshipRepository.Query( //TODO: Create Index: UserId, FriendId, Status
                q => q.Any(friendship =>
                           friendship.User.Id == user.Id &&
                           friendship.Friend.Id == probableFriend.Id &&
                           friendship.Status == FriendshipStatus.Accepted
                           )));
 }
 public bool HasFriendship(AbpUser user, AbpUser probableFriend)
 {
     return _friendshipRepository.Query( //TODO: Create Index: UserId, FriendId, Status
        q => q.Any(friendship =>
                   friendship.User.Id == user.Id &&
                   friendship.Friend.Id == probableFriend.Id &&
                   friendship.Status == FriendshipStatus.Accepted
                 ));
 }
Esempio n. 4
0
        private async Task SignInAsync(AbpUser user, bool isPersistent)
        {
            AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
            var identity = await _userManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);

            identity.AddClaim(new Claim(AbpClaimTypes.TenantId, "42"));
            AuthenticationManager.SignIn(new AuthenticationProperties {
                IsPersistent = isPersistent
            }, identity);
        }
Esempio n. 5
0
        public bool CanAssignTask(AbpUser assignerUser, AbpUser userToAssign)
        {
            if (assignerUser.Id == userToAssign.Id) //TODO: Override == to be able to write just assignerUser == userToAssign
            {
                return true;
            }

            var friendship = _friendshipRepository.GetOrNull(assignerUser.Id, userToAssign.Id, true);
            if (friendship == null)
            {
                return false;
            }

            return friendship.CanAssignTask;
        }
Esempio n. 6
0
        public bool CanAssignTask(AbpUser assignerUser, AbpUser userToAssign)
        {
            if (assignerUser.Id == userToAssign.Id) //TODO: Override == to be able to write just assignerUser == userToAssign
            {
                return(true);
            }

            var friendship = _friendshipRepository.GetOrNull(assignerUser.Id, userToAssign.Id, true);

            if (friendship == null)
            {
                return(false);
            }

            return(friendship.CanAssignTask);
        }
        private void SendConfirmationEmail(AbpUser user)
        {
            var mail = new MailMessage();

            mail.To.Add(user.EmailAddress);
            mail.IsBodyHtml      = true;
            mail.Subject         = "Email confirmation for Taskever";
            mail.SubjectEncoding = Encoding.UTF8;

            var mailBuilder = new StringBuilder();

            mailBuilder.Append(
                @"<!DOCTYPE html>
<html lang=""en"" xmlns=""http://www.w3.org/1999/xhtml"">
<head>
    <meta charset=""utf-8"" />
    <title>{TEXT_HTML_TITLE}</title>
    <style>
        body {
            font-family: Verdana, Geneva, 'DejaVu Sans', sans-serif;
            font-size: 12px;
        }
    </style>
</head>
<body>
    <h3>{TEXT_WELCOME}</h3>
    <p>{TEXT_DESCRIPTION}</p>
    <p>&nbsp;</p>
    <p><a href=""http://www.taskever.com/Account/ConfirmEmail?UserId={USER_ID}&ConfirmationCode={CONFIRMATION_CODE}"">http://www.taskever.com/Account/ConfirmEmail?UserId={USER_ID}&amp;ConfirmationCode={CONFIRMATION_CODE}</a></p>
    <p>&nbsp;</p>
    <p><a href=""http://www.taskever.com"">http://www.taskever.com</a></p>
</body>
</html>");

            mailBuilder.Replace("{TEXT_HTML_TITLE}", "Email confirmation for Taskever");
            mailBuilder.Replace("{TEXT_WELCOME}", "Welcome to Taskever.com!");
            mailBuilder.Replace("{TEXT_DESCRIPTION}",
                                "Click the link below to confirm your email address and login to the Taskever.com");
            mailBuilder.Replace("{USER_ID}", user.Id.ToString());
            mailBuilder.Replace("{CONFIRMATION_CODE}", user.EmailConfirmationCode);

            mail.Body         = mailBuilder.ToString();
            mail.BodyEncoding = Encoding.UTF8;

            _emailService.SendEmail(mail);
        }
        private void SendPasswordResetLinkEmail(AbpUser user)
        {
            var mail = new MailMessage();

            mail.To.Add(user.EmailAddress);
            mail.IsBodyHtml      = true;
            mail.Subject         = "Password reset for Taskever";
            mail.SubjectEncoding = Encoding.UTF8;

            var mailBuilder = new StringBuilder();

            mailBuilder.Append(
                @"<!DOCTYPE html>
<html lang=""en"" xmlns=""http://www.w3.org/1999/xhtml"">
<head>
    <meta charset=""utf-8"" />
    <title>{TEXT_HTML_TITLE}</title>
    <style>
        body {
            font-family: Verdana, Geneva, 'DejaVu Sans', sans-serif;
            font-size: 12px;
        }
    </style>
</head>
<body>
    <h3>{TEXT_WELCOME}</h3>
    <p>{TEXT_DESCRIPTION}</p>
    <p>&nbsp;</p>
    <p><a href=""http://www.taskever.com/Account/ResetPassword?UserId={USER_ID}&ResetCode={RESET_CODE}"">http://www.taskever.com/Account/ResetPassword?UserId={USER_ID}&amp;ResetCode={RESET_CODE}</a></p>
    <p>&nbsp;</p>
    <p><a href=""http://www.taskever.com"">http://www.taskever.com</a></p>
</body>
</html>");

            mailBuilder.Replace("{TEXT_HTML_TITLE}", "Password reset for Taskever");
            mailBuilder.Replace("{TEXT_WELCOME}", "Reset your password on Taskever!");
            mailBuilder.Replace("{TEXT_DESCRIPTION}", "Click the link below to reset your password on the Taskever.com");
            mailBuilder.Replace("{USER_ID}", user.Id.ToString());
            mailBuilder.Replace("{RESET_CODE}", user.PasswordResetCode);

            mail.Body         = mailBuilder.ToString();
            mail.BodyEncoding = Encoding.UTF8;

            _emailService.SendEmail(mail);
        }
Esempio n. 9
0
 public bool CanSeeTasksOfUser(AbpUser requesterUser, AbpUser userOfTasks)
 {
     return requesterUser.Id == userOfTasks.Id ||
            _friendshipDomainService.HasFriendship(requesterUser, userOfTasks);
 }
 public bool CanSeeProfile(AbpUser requesterUser, AbpUser targetUser)
 {
     return requesterUser.Id == targetUser.Id || _friendshipDomainService.HasFriendship(requesterUser, targetUser);
 }
Esempio n. 11
0
 public bool CanChangeFriendshipProperties(AbpUser user, Friendship friendShip)
 {
     //Can change only his own friendships.
     return(user.Id == friendShip.User.Id);
 }
        private void SendPasswordResetLinkEmail(AbpUser user)
        {
            var mail = new MailMessage();
            mail.To.Add(user.EmailAddress);
            mail.IsBodyHtml = true;
            mail.Subject = "Password reset for Taskever";
            mail.SubjectEncoding = Encoding.UTF8;

            var mailBuilder = new StringBuilder();
            mailBuilder.Append(
                @"<!DOCTYPE html>
<html lang=""en"" xmlns=""http://www.w3.org/1999/xhtml"">
<head>
    <meta charset=""utf-8"" />
    <title>{TEXT_HTML_TITLE}</title>
    <style>
        body {
            font-family: Verdana, Geneva, 'DejaVu Sans', sans-serif;
            font-size: 12px;
        }
    </style>
</head>
<body>
    <h3>{TEXT_WELCOME}</h3>
    <p>{TEXT_DESCRIPTION}</p>
    <p>&nbsp;</p>
    <p><a href=""http://www.taskever.com/Account/ResetPassword?UserId={USER_ID}&ResetCode={RESET_CODE}"">http://www.taskever.com/Account/ResetPassword?UserId={USER_ID}&amp;ResetCode={RESET_CODE}</a></p>
    <p>&nbsp;</p>
    <p><a href=""http://www.taskever.com"">http://www.taskever.com</a></p>
</body>
</html>");

            mailBuilder.Replace("{TEXT_HTML_TITLE}", "Password reset for Taskever");
            mailBuilder.Replace("{TEXT_WELCOME}", "Reset your password on Taskever!");
            mailBuilder.Replace("{TEXT_DESCRIPTION}", "Click the link below to reset your password on the Taskever.com");
            mailBuilder.Replace("{USER_ID}", user.Id.ToString());
            mailBuilder.Replace("{RESET_CODE}", user.PasswordResetCode);

            mail.Body = mailBuilder.ToString();
            mail.BodyEncoding = Encoding.UTF8;

            _emailService.SendEmail(mail);
        }
Esempio n. 13
0
 public bool CanChangeFriendshipProperties(AbpUser user, Friendship friendShip)
 {
     //Can change only his own friendships.
     return user.Id == friendShip.User.Id;
 }
Esempio n. 14
0
 public bool CanRemoveFriendship(AbpUser currentUser, Friendship friendship)
 {
     return(friendship.User.Id == currentUser.Id);
 }
Esempio n. 15
0
 public AbpUsersLocalTestData()
 {
     John  = new AbpUser(Guid.NewGuid(), "john");
     David = new AbpUser(Guid.NewGuid(), "david", "*****@*****.**");
 }
Esempio n. 16
0
 public bool CanDeleteTask(AbpUser user, Task task)
 {
     return((task.CreatorUserId == user.Id) || (task.AssignedUser.Id == user.Id));
 }
Esempio n. 17
0
 public bool CanSeeTasksOfUser(AbpUser requesterUser, AbpUser userOfTasks)
 {
     return(requesterUser.Id == userOfTasks.Id ||
            _friendshipDomainService.HasFriendship(requesterUser, userOfTasks));
 }
Esempio n. 18
0
 public bool CanSeeProfile(AbpUser requesterUser, AbpUser targetUser)
 {
     return(requesterUser.Id == targetUser.Id || _friendshipDomainService.HasFriendship(requesterUser, targetUser));
 }
Esempio n. 19
0
 public bool CanDeleteTask(AbpUser user, Task task)
 {
     return (task.CreatorUserId == user.Id) || (task.AssignedUser.Id == user.Id);
 }
        private void SendConfirmationEmail(AbpUser user)
        {
            var mail = new MailMessage();
            mail.To.Add(user.EmailAddress);
            mail.IsBodyHtml = true;
            mail.Subject = "Email confirmation for Taskever";
            mail.SubjectEncoding = Encoding.UTF8;

            var mailBuilder = new StringBuilder();
            mailBuilder.Append(
                @"<!DOCTYPE html>
<html lang=""en"" xmlns=""http://www.w3.org/1999/xhtml"">
<head>
    <meta charset=""utf-8"" />
    <title>{TEXT_HTML_TITLE}</title>
    <style>
        body {
            font-family: Verdana, Geneva, 'DejaVu Sans', sans-serif;
            font-size: 12px;
        }
    </style>
</head>
<body>
    <h3>{TEXT_WELCOME}</h3>
    <p>{TEXT_DESCRIPTION}</p>
    <p>&nbsp;</p>
    <p><a href=""http://www.taskever.com/Account/ConfirmEmail?UserId={USER_ID}&ConfirmationCode={CONFIRMATION_CODE}"">http://www.taskever.com/Account/ConfirmEmail?UserId={USER_ID}&amp;ConfirmationCode={CONFIRMATION_CODE}</a></p>
    <p>&nbsp;</p>
    <p><a href=""http://www.taskever.com"">http://www.taskever.com</a></p>
</body>
</html>");

            mailBuilder.Replace("{TEXT_HTML_TITLE}", "Email confirmation for Taskever");
            mailBuilder.Replace("{TEXT_WELCOME}", "Welcome to Taskever.com!");
            mailBuilder.Replace("{TEXT_DESCRIPTION}",
                "Click the link below to confirm your email address and login to the Taskever.com");
            mailBuilder.Replace("{USER_ID}", user.Id.ToString());
            mailBuilder.Replace("{CONFIRMATION_CODE}", user.EmailConfirmationCode);

            mail.Body = mailBuilder.ToString();
            mail.BodyEncoding = Encoding.UTF8;

            _emailService.SendEmail(mail);
        }
Esempio n. 21
0
 public bool CanRemoveFriendship(AbpUser currentUser, Friendship friendship)
 {
     return friendship.User.Id == currentUser.Id;
 }