Пример #1
0
 public static Token RegisterMember(Login entity)
 {
     var user = Membership.CreateUser(entity.username, entity.password, entity.email);
     if (user.ProviderUserKey != null)
     {
         var token = AuthManager.GenerateToken(new Guid(user.ProviderUserKey.ToString()), string.Empty, string.Empty);
         return new Token() { oauth_timestamp = DateTime.Now.ToString(), oauth_token = token };
     }
     throw new WebFaultException(HttpStatusCode.InternalServerError);
 }
Пример #2
0
Файл: Auth.cs Проект: MPCC/MPCC
        public GetResponse<Token> RequestToken(Login entity)
        {
            var token = AuthRepository.Login(entity);
            var cookie = new HttpCookie("_mpcc", "OAuth oauth_token=" + token.oauth_token);

            HttpContext.Current.Response.SetCookie(cookie);
            HttpContext.Current.Response.Headers.Add("Authorization", "OAuth oauth_token=" + token.oauth_token);
            HttpContext.Current.Response.Headers.Add("Access-Control-Allow-Origin", "*");
            HttpContext.Current.Response.Headers.Add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE");
            HttpContext.Current.Response.Headers.Add("Access-Control-Allow-Headers", "Authorization,content-type,applicationid");

            return new GetResponse<Token>() { Entity = token };
        }
Пример #3
0
 public static Token Login(Login entity)
 {
     if (Membership.ValidateUser(entity.username, entity.password))
     {
         var user = Membership.GetUser(entity.username);
         if (user != null)
         {
             if (user.ProviderUserKey != null)
             {
                 var token = AuthManager.GenerateToken(new Guid(user.ProviderUserKey.ToString()), string.Empty, string.Empty);
                 return new Token() { oauth_timestamp = DateTime.Now.ToString(), oauth_token = token};
             }
         }
     }
     throw new WebFaultException(HttpStatusCode.Unauthorized);
 }
Пример #4
0
Файл: Auth.cs Проект: MPCC/MPCC
 public GetResponse<Token> RegisterMember(Login entity)
 {
     return new GetResponse<Token>() { Entity = AuthRepository.RegisterMember(entity) };
 }