Ejemplo n.º 1
0
        public void AddUser(string email, string password)
        {
            VcapJsonRequest r = BuildVcapJsonRequest(Method.POST, Constants.UsersResource);

            r.AddBody(new { email, password });
            r.Execute();
        }
Ejemplo n.º 2
0
        public void ChangePassword(string user, string newPassword)
        {
            VcapRequest   request  = BuildVcapRequest(Constants.UsersResource, user);
            IRestResponse response = request.Execute();

            JObject parsed = JObject.Parse(response.Content);

            parsed["password"] = newPassword;

            VcapJsonRequest put = BuildVcapJsonRequest(Method.PUT, Constants.UsersResource, user);

            put.AddBody(parsed);
            put.Execute();
        }
Ejemplo n.º 3
0
        public void Login(string email, string password)
        {
            VcapJsonRequest r = BuildVcapJsonRequest(Method.POST, Constants.UsersResource, email, "tokens");

            r.AddBody(new { password });

            try
            {
                IRestResponse response = r.Execute();
                var           parsed   = JObject.Parse(response.Content);
                string        token    = parsed.Value <string>("token");
                CredentialManager.RegisterToken(token);
            }
            catch (VcapAuthException)
            {
                throw new VcapAuthException(string.Format(Resources.Vmc_LoginFail_Fmt, CredentialManager.CurrentTarget));
            }
        }