// GET api/empsvc
 public HttpResponseMessage GetAuthToken(string username, string pwd)
 {
     try
     {
         string         val = ""; TokenDTO tokenData = null;;
         var            tokenGenerator = new Firebase.TokenGenerator("8CWDFfXY250C2EM6Gb3I0g4TrxftS9QqE9O29Y3e");
         ADAuth.Service ADSvr          = new ADAuth.Service();
         //val = ADSvr.ADValidateUser(username, pwd);///uncomment on depolyment to production
         val = "true";
         if (val.ToLower().Contains("true"))
         {
             AppUser usr = new AppUser();
             usr = Utility.GetUser(username);
             if (usr != null)
             {
                 var authPayload = new Dictionary <string, object>()
                 {
                     { "uid", usr.EmployeeID },
                     { "personID", usr.PersonID },
                     { "fullName", usr.FullName },
                     { "jobTitle", usr.JobTitle },
                     { "department", usr.Department },
                     { "gender", usr.Gender },
                     { "email", usr.Email }
                 };
                 string token = tokenGenerator.CreateToken(authPayload);
                 tokenData = new TokenDTO()
                 {
                     Token = token, StatusCode = "000"
                 };
                 //return token;
             }
             else
             {
                 tokenData = new TokenDTO()
                 {
                     Token = "NOT FOUND", StatusCode = "001"
                 };
                 //return "NOT FOUND";
             }
         }
         else
         {
             tokenData = new TokenDTO()
             {
                 Token = "INVALID", StatusCode = "002"
             };
         }
         return(Request.CreateResponse <TokenDTO>(HttpStatusCode.OK, tokenData));
     }
     catch (Exception ex)
     {
         Utility.WriteError("Error msg: " + ex.Message + " StackTrace: " + ex.StackTrace);
         return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "An error occurred!!"));
     }
 }
Esempio n. 2
0
        public virtual JsonResult GetToken()
        {
            var tokenGenerator = new Firebase.TokenGenerator(ConfigurationManager.AppSettings.Get("FirebaseUserToken"));
            var authPayload    = new Dictionary <string, object>()
            {
                { "uid", "app" },
            };

            return(Json(tokenGenerator.CreateToken(authPayload)));
        }
Esempio n. 3
0
 public string GetFirebaseToken(string user, string uid, string data)
 {
     var tokenGenerator = new Firebase.TokenGenerator(_firebaseSecret);
     var authPayload = new Dictionary<string, object>()
     {
         {"uid", uid},
         {"user", user},
         {"data", data}
     };
     string token = tokenGenerator.CreateToken(authPayload);
     return token;
 }
Esempio n. 4
0
        private void btnCreateToken_Click(object sender, EventArgs e)
        {
            var tokenGenerator = new Firebase.TokenGenerator(SECRET);
            var authPayload    = new Dictionary <string, object>()
            {
                { "uid", this.txtUserId.Text },
                { "UserId", this.txtUserId.Text },
                { "Role", "user" }
            };

            string token = tokenGenerator.CreateToken(authPayload, new Firebase.TokenOptions(expires: new DateTime(2016, 5, 1), debug: true));

            this.txtAuthToken.Text = token;


            FirebaseApp App = new FirebaseApp(new Uri(FBPATHPRIVATE), token);
        }
Esempio n. 5
0
        private void btnCreateToken_Click(object sender, EventArgs e)
        {

            var tokenGenerator = new Firebase.TokenGenerator(SECRET);
            var authPayload = new Dictionary<string, object>()
                {
                  { "uid", this.txtUserId.Text }, 
                  { "UserId", this.txtUserId.Text },
                  { "Role", "user" }
                };

            string token = tokenGenerator.CreateToken(authPayload, new Firebase.TokenOptions(expires: new DateTime(2016, 5, 1), debug: true));
            this.txtAuthToken.Text = token;


            FirebaseApp App = new FirebaseApp(new Uri(FBPATHPRIVATE), token);

        }