Esempio n. 1
0
        public SeerefineIdentity(Login login, User user)
        {
            UserName = login.Username;
            Claims = login.Roles.Select(x => x.ToString()).ToArray();
            ClientId = login.ClientId;
            Teams = new List<Tuple<string, string>>();

            if (user != null)
            {
                Teams = new List<Tuple<string, string>>()
                    {
                        Tuple.Create(user.TeamId, user.TeamName),
                    };
            }
        }
Esempio n. 2
0
        public ManageUsersModule(ISessionProvider sessionProvider, IDispatchEvents eventDispatcher)
            : base(sessionProvider, eventDispatcher, "/manage/clients/{id}")
        {
            Get["/users/create"] = parameters => View["views/manage/_createUser.html", new {ClientId}];

            Get["/users/list"] = parameters =>
                {
                    var users = RavenSession.Query<User>()
                                            .Where(x => x.ClientId == ClientId)
                                            .ToList();

                    var viewModel = new
                        {
                            data = users.Select(x => new {title = x.Id, content = x.Name}),
                        };

                    return Response.AsJson(viewModel);
                };

            Get["/users/wihtoutteam"] = parameters =>
                {
                    var users = RavenSession.Query<User>()
                                            .Where(x => x.ClientId == ClientId && x.TeamId == null);

                    return Response.AsJson(users);
                };

            Post["/users/create"] = parameters =>
                {

                    var command = this.Bind<CreateLoginCommand>();

                    if (command.AuthenticationKey == Guid.Empty)
                        command.AuthenticationKey = Guid.NewGuid();

                    var login = new Login
                        {
                            AuthenticationKey = command.AuthenticationKey,
                            ClientId = ClientId,
                            Username = command.UserName,
                            Password = command.Password,
                            Roles = new List<Roles> {Roles.ClientUser},
                        };

                    RavenSession.Store(login);

                    var user = new User
                        {
                            ClientId = ClientId,
                            Name = Request.Form["Name"],
                            LoginId = login.Id,
                        };

                    RavenSession.Store(user);

                    RavenSession.Store(new UserNameAndPasswordIsUnique
                        {
                            Id = command.ToUniqueString(),
                            AuthenticationKey = command.AuthenticationKey,
                        });

                    RavenSession.SaveChanges();

                    return HttpStatusCode.NoContent;
                };
        }
Esempio n. 3
0
        public void Multiple_reminders_should_result_in_multiple_verificationquestions_on_DetailViewModel()
        {
            var authenticationKey = Guid.NewGuid();

            var browser = new Browser(with =>
                {
                    with.ApplicationStartup(Bootstrapper.ApplicationConfiguration);
                    with.AllDiscoveredModules();
                    with.EnableAutoRegistration();
                });

            using (var session = new RavenSessionProvider().GetSession())
            {
                var login = new Login
                    {
                        AuthenticationKey = authenticationKey,
                        ClientId = "clients/1",
                        Username = "******",
                        Password = "******",
                        Roles = new List<Roles>() {Roles.ClientUser},
                    };

                session.Store(login);

                session.Store(new User
                    {
                        ClientId = "clients/1",
                        LoginId = login.Id,
                        Name = "Anna",
                        TeamId = "clients/1/teams/1",
                        TeamName = "Team 1",
                    });

                session.Store(new ScheduleItem
                    {
                        ClientId = "clients/1",
                        Date = "20130711",
                        CurrentStatus = ScheduleItemStatus.CheckedIn,
                    });

                session.Store(new SectionDetail
                    {
                        ClientId = "clients/1",
                        Id = "clients/1/sites/1/infosections/1/details/1",
                    });

                session.SaveChanges();
            }

            var response = browser
                .Post("/weblogin", with =>
                    {
                        with.HttpRequest();
                        with.FormValue("UserName", "Anna");
                        with.FormValue("Password", "Sommar");
                    })
                .Then
                .Post("/process/clients/1/scheduleItems/1/detailnotes", with =>
                {
                    with.HttpRequest();
                    with.JsonBody(new DetailNotesAdded
                        {
                            SectionDetailId = "clients/1/sites/1/infosections/1/details/1",
                            Timestamp = "Thu Jul 11 2013 10:53:21 GMT+02:00 (CEST)",
                            orderItems = new[] {new OrderItem
                                {
                                    units = "1st",
                                    name = "fuxia",
                                }, },
                            Reminders = new List<string>()
                                {
                                    "Check waterlevel",
                                    "Shaping",
                                },
                        });
                });

            Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
            using (var session = new RavenSessionProvider().GetSession())
            {
                var detail = session.Load<SectionDetail>("clients/1/sites/1/infosections/1/details/1");

                Assert.NotEmpty(detail.VerificationQuestion);
            }
        }