Esempio n. 1
0
        public ActionResult Index()
        {
            ApplicationUser user     = null;
            var             userInfo = TempData["User"];

            if (!string.IsNullOrEmpty(userInfo as string))
            {
                user = JsonConvert.DeserializeObject <ApplicationUser>(userInfo as string);
            }
            var context = this.Url.ActionContext.HttpContext;
            var query   = context.Request.Query;
            var code    = string.Empty;
            var state   = string.Empty;

            if (query.ContainsKey("code"))
            {
                code = query["code"];
            }
            if (query.ContainsKey("session_state"))
            {
                state = query["session_state"];
            }
            var signIn = false;
            var token  = string.Empty;

            //var tenant = "__YOUR TENANT__";//this grant_type allows common
            //var clientId = "__APP CLIENT ID__";
            //var redirectUri = "http://*****:*****@"[a-z | A-Z]*")).Trim();
                    ViewBag.AccountName = user.GlobalName;
                }
            }
            ViewBag.IsSignin = signIn;
            ViewBag.Menu     = new List <string>();
            ViewBag.Message  = string.Empty;
            ViewBag.Title    = "Show user information";
            return(View(new IndexViewModel
            {
                Comments = _comments.Take(COMMENTS_PER_PAGE).ToList().AsReadOnly(),
                CommentsPerPage = COMMENTS_PER_PAGE,
                Page = 1
            }));
        }
Esempio n. 2
0
        public ActionResult Index()
        {
            var context = this.Url.ActionContext.HttpContext;
            var query   = context.Request.Query;
            var code    = string.Empty;
            var state   = string.Empty;

            if (query.ContainsKey("code"))
            {
                code = query["code"];
            }
            if (query.ContainsKey("session_state"))
            {
                state = query["session_state"];
            }
            var signIn      = false;
            var accountName = string.Empty;
            var token       = string.Empty;

            if (!string.IsNullOrEmpty(code))
            {
                var tenant      = "__YOUR TENANT__";           //this grant_type allows common
                var clientId    = "__APP CLIENT ID__";
                var redirectUri = "http://*****:*****@"[a-z | A-Z]*")).Trim();
            }
            ViewBag.AccountName = accountName;
            ViewBag.IsSignin    = signIn;
            ViewBag.Menu        = new List <string>();
            ViewBag.Message     = string.Empty;
            ViewBag.Title       = "Show user information";
            return(View(new IndexViewModel
            {
                Comments = _comments.Take(COMMENTS_PER_PAGE).ToList().AsReadOnly(),
                CommentsPerPage = COMMENTS_PER_PAGE,
                Page = 1
            }));
        }
Esempio n. 3
0
        public ActionResult Index()
        {
            ApplicationUser user     = null;
            var             userInfo = TempData["User"];

            if (!string.IsNullOrEmpty(userInfo as string))
            {
                user = JsonConvert.DeserializeObject <ApplicationUser>(userInfo as string);
            }
            var context = this.Url.ActionContext.HttpContext;
            var query   = context.Request.Query;
            var code    = string.Empty;
            var state   = string.Empty;

            if (query.ContainsKey("code"))
            {
                code = query["code"];
            }
            if (query.ContainsKey("session_state"))
            {
                state = query["session_state"];
            }
            var signIn = false;
            var token  = string.Empty;

            if (!string.IsNullOrEmpty(code))
            {
                user.AccessList.LastOrDefault().Secret      = "__CLIENT SECRET__";
                user.AccessList.LastOrDefault().AuthCode    = code;
                user.AccessList.LastOrDefault().AADEndPoint = "v2.0";
                signIn = new AccessGraph().GetToken(user);
                if (signIn)
                {
                    new AccessGraph().SetUserInfo(user);
                    //Regist '���� �N�N�iTetsuro Takao�j' as Azure Active Directory account.
                    user.GlobalName     = string.Join("", Regex.Matches(user.displayName, @"[a-z | A-Z]*")).Trim();
                    ViewBag.AccountName = user.GlobalName;
                    var grant   = "{\"password\":\"__PASSWORD__\",\"username\":\"__ACCOUNT__\"}";
                    var history = new AccessHistory();
                    history.GrantType = grant;
                    history.Scope     = "files.readwrite";
                    history.TenantID  = user.AccessList.FirstOrDefault().TenantID;
                    history.Redirect  = user.AccessList.FirstOrDefault().Redirect;
                    history.ClientId  = user.AccessList.FirstOrDefault().ClientId;
                    history.Secret    = user.AccessList.FirstOrDefault().Secret;
                    user.AccessList.Add(history);
                    if (new AccessGraph().GetToken(user))
                    {
                        var webLink = new AccessGraph().GetLink("01N7LZHZCQ2D4PKWJ4OJAKWEOBBJWTCOWG", user);
                    }
                }
            }
            ViewBag.IsSignin = signIn;
            ViewBag.Menu     = new List <string>();
            ViewBag.Message  = string.Empty;
            ViewBag.Title    = "Show user information";
            return(View(new IndexViewModel
            {
                Comments = _comments.Take(COMMENTS_PER_PAGE).ToList().AsReadOnly(),
                CommentsPerPage = COMMENTS_PER_PAGE,
                Page = 1
            }));
        }