Exemple #1
0
        public UserModule(Authentication auth)
            : base("/API/User")
        {
            Get["/"] = _ =>
            {
                return auth.Verify(Authentication.SessionIdFromRequest(Request));
            };

            Post["/"] = _ =>
            {
                return auth.Register(new User(this.Bind<UserLogin>()));
            };
        }
Exemple #2
0
        public MessageModule(Authentication auth)
            : base("/API/Message")
        {
            Post["/"] = _ =>
            {
                User user = auth.Verify(Authentication.SessionIdFromRequest(Request));
                if (user == null)
                {
                    return HttpStatusCode.Unauthorized;
                }

                auth.Send(user, this.Bind<Message>());
                return user;
            };
        }