public string CreateTestAndReturnName(string testName) { if (AuthCheck.NewCheck().MustBeInRole("Dev").IsNotSatisfiedBy(_currentUserFactory.GetCurrentUser())) { throw new UserNotAuthorisedException(); } Guid newTestId = Guid.NewGuid(); TestSaveCommand cmd = new TestSaveCommand() { Id = newTestId, TestName = testName }; _commandProcessor.Execute(cmd); TestQuery qry = new TestQuery() { Id = newTestId }; Test domainEntity = _queryProcessor.Execute(qry); if (domainEntity != null) { return(domainEntity.TestName); } else { throw new Exception("Couldn't get test from database."); } }
public void SetupCloud(int cloudType) { if (_NaviStatus == NavigationStatus.Processing) { return; } if (_userDrive == null) { _userDrive = new bUserCloudDrive(); } _currCloudType = cloudType; _userDrive.Setup(_googleDirve); _userDrive.Initialize(cloudType); StartLoading(); _NaviStatus = NavigationStatus.Processing; _userDrive.StartAuthentication(delegate(bool res, int resCode) { FinishLoading(); _NaviStatus = NavigationStatus.NotProcessing; if (res) { if (resCode == 1) { Debug.Log("Credential Error"); credentialError.gameObject.SetActive(true); credError = true; // close the application and retry again. } else { credentialError.gameObject.SetActive(false); _userDrive.GetFileListFromPath("/", CreatePanels); } _authCheck = AuthCheck.Succeed; _timerForAuth = 0; } else { _authCheck = AuthCheck.failed; Icon_AuthFailed.SetActive(true); } }); }
public void Initialize() { ResetIcons(); _NaviStatus = NavigationStatus.NotProcessing; _authCheck = AuthCheck.failed; _currCloudType = 0; isButtonSelected = false; //ETC _empty = ""; _isReseting = false; _isCopy = false; credentialError.SetActive(false); credError = false; FinishLoading(); }
// Ermöglicht es, einen bestimmten Gruppeneintrag zu löschen (Import: gruppenEintragID, Export: gruppenEintrageModel) // redirect auf error view, fallls keine authorizierung vorliegt. // GET: GruppenEintraege/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var userId = User.Identity.GetUserId(); int idauth = (int)id; if (AuthCheck.VerantGr(idauth, userId) || AuthCheck.AutorGE(idauth, userId) || User.IsInRole("Admin")) { GruppenEintraege gruppenEintraege = db.GruppenEintraeges.Find(id); if (gruppenEintraege == null) { return(HttpNotFound()); } return(View(gruppenEintraege)); } return(RedirectToAction("Unauthorized", "Error")); }
// Ermöglicht das Bearbeiten eines Lehrstuhls (Import: LehrstuhlID, Export: LehrstuhlModel) // import: lehrstuhlid // export: lehrstuhlmodel // redirect auf error view, falls keine authorizierung vorliegt // GET: Lehrstuhl/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var userId = User.Identity.GetUserId(); int idauth = (int)id; if (AuthCheck.VerantLehr(idauth, userId) || User.IsInRole("Admin")) { Lehrstuhl lehrstuhl = db.Lehrstuhls.Find(id); if (lehrstuhl == null) { return(HttpNotFound()); } return(View(lehrstuhl)); } return(RedirectToAction("Unauthorized", "Error")); }
/// <summary> /// Verify that the NPSSO the user recieved is valid. Not required for logging in but useful to check during /// the login process. /// </summary> /// <param name="NPSSO">The users NPSSO id.</param> /// <returns>A blank result object. If the key is valid, IsSuccess with return true.</returns> public async Task <Result> AuthorizeCheckAsync(string NPSSO) { using (var client = new HttpClient()) { var authorizeCheck = new AuthCheck() { Npsso = NPSSO, ClientId = Oauth.ClientID, Scope = Oauth.Scope, ServiceEntity = Oauth.ServiceEntity }; var json = JsonConvert.SerializeObject(authorizeCheck); var stringContent = new StringContent(json, Encoding.UTF8, "application/json"); // Call auth check so we can continue the flow... var result = await client.PostAsync(EndPoints.AuthorizeCheck, stringContent); return(new Result() { IsSuccess = result.IsSuccessStatusCode }); } }
// Liefert eine Liste von Gruppeneinträgen. Diese List enthält nur die Einträge einer bestimmten Gruppe, falls // eine GruppenID übergeben wird, ansonsten werden die Einträge aller Gruppen zurückgegeben // (Import optional: GruppenID, Export: GruppenEinträge List) // GET: GruppenEintraege public ActionResult Index(int?gruppenid) { List <GruppenEintraege> entries = new List <GruppenEintraege>(); List <Person> zuordnung = new List <Person>(); String userid = ""; Boolean ok = false; // für prüfung auf mitgliedschaft Boolean[] verantwortlich = new Boolean[10000]; // Index gruppenid, Eintrag false -> Gruppe gruppenid kein Verantwortlicher Boolean[] autor = new Boolean[10000]; // Index gruppenid, Eintrag false -> Gruppe gruppenid kein autor var userId = User.Identity.GetUserId(); foreach (Gruppe gruppe in db.Gruppes) { // Wenn die Gruppe privat ist, dann prüfe, ob User Mitglied der Gruppe ist // falls ja oder gruppe nicht privat, dann OK und weiter (Admin sieht alles immer) if (gruppe.gruppenid == gruppenid && gruppe.privat == true && !User.IsInRole("Admin")) { // hier werden PRIVATEN alle Gruppen ausgeschlossen, in denen der User nicht Mitglied ist ok = false; foreach (MitgliederGruppe mg in db.MitgliederGruppes) { if (mg.gruppenid == gruppe.gruppenid && mg.userid == userId) { ok = true; } } } else { ok = true; } } if (ok) { if (gruppenid == null) { return(View(db.GruppenEintraeges.ToList())); } else { foreach (GruppenEintraege ge in db.GruppenEintraeges) { // Signal an Frontend, ob User auch autor ist und bearbeiten/löschen darf autor[ge.id] = AuthCheck.AutorGE(ge.id, userId); // Signal an Frontend, ob User auch Verantwortlicher ist und somit bearbeiten/löschen darf verantwortlich[ge.gruppenid] = AuthCheck.VerantGr(ge.gruppenid, userId); if (ge.gruppenid == gruppenid) { foreach (Person person in db.Person) { if (person.id == ge.autor) { ge.autor = HelpFunctions.GetDisplayName(person.id); userid = person.id; } } // zuordnungstabelle für verlinkung erstellen Person el = new Person(); el.id = userid; el.name = ge.autor; zuordnung.Add(el); entries.Add(ge); } } ViewBag.zuordnung = zuordnung; ViewBag.autor = autor; ViewBag.verantwortlich = verantwortlich; // Bezeichnung der Gruppe in View übergeben foreach (Gruppe gr in db.Gruppes) { if (gr.gruppenid == gruppenid) { ViewBag.bezeichnung = gr.bezeichnung; } } } } return(View(entries.ToList())); }
// Liefert eine Liste von Lehrstuhleinträgen. Diese List enthält nur die Einträge eines bestimmten Lehrstuhls, falls // eine lehrstuhlID übergeben wird, ansonsten werden die Einträge aller lehrstühle zurückgegeben // (Import optional: lehrstuhlID, Export: lehrstuhlEinträge List) // GET: LehrstuhlEintraege public ActionResult Index(int?lehrstuhlid) { List <LehrstuhlEintraege> entries = new List <LehrstuhlEintraege>(); List <Person> zuordnung = new List <Person>(); String userid = ""; Boolean ok = false; // für prüfung auf mitgliedschaft Boolean[] verantwortlich = new Boolean[10000]; // Index gruppenid, Eintrag false -> Gruppe gruppenid kein Verantwortlicher Boolean[] autor = new Boolean[10000]; // Index gruppenid, Eintrag false -> Gruppe gruppenid kein autor var userId = User.Identity.GetUserId(); foreach (Lehrstuhl l in db.Lehrstuhls) { // Wenn der lehrstuhl privat ist, dann prüfe, ob User mitarbeiter des lehrstuhls ist // falls ja oder lehrstuhl nicht privat, dann OK und weiter (Admin sieht alles immer) if (l.lehrstuhlid == lehrstuhlid && l.privat == true && !User.IsInRole("Admin")) { // hier werden PRIVATEN alle lehrstühle ausgeschlossen, in denen der User nicht mitarbeiter ist ok = false; foreach (MitarbeiterLehrstuhl ml in db.MitarbeiterLehrstuhls) { if (ml.lehrstuhlid == l.lehrstuhlid && ml.userid == userId) { ok = true; } } } else { ok = true; } } if (ok) { if (lehrstuhlid == null) { return(View(db.LehrstuhlEintraeges.ToList())); } else { foreach (LehrstuhlEintraege le in db.LehrstuhlEintraeges) { // Signal an Frontend, ob User auch Verantwortlicher ist und somit bearbeiten/löschen darf autor[le.id] = AuthCheck.AutorLE(le.id, userId); verantwortlich[le.lehrstuhlid] = AuthCheck.VerantLehr(le.lehrstuhlid, userId); if (le.lehrstuhlid == lehrstuhlid) { foreach (Person person in db.Person) { if (person.id == le.autor) { ViewBag.mail = person.AspNetUsers.Email; le.autor = HelpFunctions.GetDisplayName(person.id); userid = person.id; } } // zuordnungstabelle für verlinkung erstellen Person el = new Person(); el.id = userid; el.name = le.autor; zuordnung.Add(el); entries.Add(le); } } ViewBag.zuordnung = zuordnung; ViewBag.autor = autor; ViewBag.verantwortlich = verantwortlich; // Bezeichnung des lehrstuhls in View übergeben foreach (Lehrstuhl le in db.Lehrstuhls) { if (le.lehrstuhlid == lehrstuhlid) { ViewBag.bezeichnung = le.bezeichnung; } } } } return(View(entries.ToList())); }
//////////////////////// /// Lehrstuhleinträge //////////////////// // Index View der Newsfeed Seite, die das NewsfeedModel verwendet // Import: keine // Export: NewsfeedModel + diverse ViewBags public ActionResult Index() { List <NewsFeedModel> list = new List <NewsFeedModel>(); List <Person> zuordnung = new List <Person>(); Boolean[] lverantwortlich = new Boolean[10000]; // Index lehrstuhlid, Eintrag false -> lehrstuhl lehrstuhlid kein Verantwortlicher Boolean[] lautor = new Boolean[10000]; // Index lehrstuhlid, Eintrag false -> lehrstuhl lehrstuhlid kein autor Boolean abonniert = false; var userId = User.Identity.GetUserId(); // Alle abonnierten Lehrstuhleinträge und relevanten (=mitglied) lehrstuhleinträge auslesen foreach (LehrstuhlEintraege le in db.LehrstuhlEintraeges) { // Signal an Frontend, ob User auch autor ist und bearbeiten/löschen darf lautor[le.id] = AuthCheck.AutorLE(le.id, userId); // Signal an Frontend, ob User auch Verantwortlicher ist und somit bearbeiten/löschen darf lverantwortlich[le.lehrstuhlid] = AuthCheck.VerantLehr(le.lehrstuhlid, userId); // prüfen, ob user mitarbeiter des lehrstuhls ist oder diesen abonniert hat foreach (MitarbeiterLehrstuhl ml in db.MitarbeiterLehrstuhls) { if (ml.lehrstuhlid == le.lehrstuhlid && ml.userid == userId || User.IsInRole("Admin")) { abonniert = true; } } foreach (AbonnentenLehrstuhl al in db.AbonnentenLehrstuhls) { if (al.lehrstuhlid == le.lehrstuhlid && al.userid == userId || User.IsInRole("Admin")) { abonniert = true; } } // Userid richtig darstellen foreach (Person person in db.Person) { if (person.id == le.autor) { le.autor = HelpFunctions.GetFeedDisplayName(person.id); // zuordnungstabelle für verlinkung erstellen zuordnung.Add(new Person { id = person.id, name = le.autor }); } } ViewBag.lautor = lautor; ViewBag.lverantwortlich = lverantwortlich; if (abonniert) { list.Add(new NewsFeedModel { id = le.id, entityid = le.lehrstuhlid, datum = le.datum, autor = le.autor, inhalt = le.inhalt, label1 = le.label1, label2 = le.label2, label3 = le.label3, label4 = le.label4, label5 = le.label5, typ = "l", entityname = HelpFunctions.GetLehrstuhlName(le.lehrstuhlid) }); } abonniert = false; } //////////////////////// /// Gruppeneinträge //////////////////// Boolean[] verantwortlich = new Boolean[10000]; // Index gruppenid, Eintrag false -> Gruppe gruppenid kein Verantwortlicher Boolean[] autor = new Boolean[10000]; // Index gruppenid, Eintrag false -> Gruppe gruppenid kein autor Boolean mitglied = false; foreach (GruppenEintraege le in db.GruppenEintraeges) { // Signal an Frontend, ob User auch autor ist und bearbeiten/löschen darf autor[le.id] = AuthCheck.AutorGE(le.id, userId); // Signal an Frontend, ob User auch Verantwortlicher ist und somit bearbeiten/löschen darf verantwortlich[le.gruppenid] = AuthCheck.VerantGr(le.gruppenid, userId); // prüfen, ob user mitglied der gruppe ist foreach (MitgliederGruppe mg in db.MitgliederGruppes) { if (mg.gruppenid == le.gruppenid && mg.userid == userId || User.IsInRole("Admin")) { mitglied = true; } } // Userid richtig darstellen foreach (Person person in db.Person) { if (person.id == le.autor) { le.autor = HelpFunctions.GetFeedDisplayName(person.id); // zuordnungstabelle für verlinkung erstellen zuordnung.Add(new Person { id = person.id, name = le.autor }); } } ViewBag.autor = autor; ViewBag.verantwortlich = verantwortlich; if (mitglied) { list.Add(new NewsFeedModel { id = le.id, entityid = le.gruppenid, datum = le.datum, autor = le.autor, inhalt = le.inhalt, label1 = le.label1, label2 = le.label2, label3 = le.label3, label4 = le.label4, label5 = le.label5, typ = "g", entityname = HelpFunctions.GetGruppenName(le.gruppenid) }); } mitglied = false; } // Gruppen und Lehrstühle müssen in eienr Partial View angezeigt werden! // var lehrstuehle = db.Lehrstuhls.ToList(); ViewBag.zuordnung = zuordnung.Distinct(); return(View(list)); }
public object Get(AuthCheck request) { return IsLoggedIn; }
public void SetupCloud(int cloudType) { if (_NaviStatus == NavigationStatus.Processing) return; if (_userDrive == null) _userDrive = new bUserCloudDrive(); _currCloudType = cloudType; _userDrive.Setup(_googleDirve); _userDrive.Initialize(cloudType); StartLoading (); _NaviStatus = NavigationStatus.Processing; _userDrive.StartAuthentication(delegate (bool res, int resCode) { FinishLoading(); _NaviStatus = NavigationStatus.NotProcessing; if (res) { if(resCode == 1){ Debug.Log("Credential Error"); credentialError.gameObject.SetActive(true); credError = true; // close the application and retry again. } else{ credentialError.gameObject.SetActive(false); _userDrive.GetFileListFromPath("/", CreatePanels); } _authCheck = AuthCheck.Succeed; _timerForAuth = 0; }else{ _authCheck = AuthCheck.failed; Icon_AuthFailed.SetActive(true); } }); }
public void Initialize(){ ResetIcons (); _NaviStatus = NavigationStatus.NotProcessing; _authCheck = AuthCheck.failed; _currCloudType = 0; isButtonSelected = false; //ETC _empty = ""; _isReseting = false; _isCopy = false; credentialError.SetActive(false); credError = false; FinishLoading (); }
// Gibt eine Liste mit allen vorhandenen Lehrstühlen zurück // import: keine // export: lehrstuhlmodel // GET: Lehrstuhl public ActionResult Index() { List <Lehrstuhl> entries = new List <Lehrstuhl>(); List <Person> zuordnung = new List <Person>(); Boolean[] verantwortlich = new Boolean[10000]; // Index lehrstuhlid, Eintrag false -> lehrstuhl kein Verantwortlicher Boolean[] mitarbeiter = new Boolean[10000]; // Index lehrstuhlid, Eintrag false -> lehrstuhl kein mitarbeiter Boolean ok = false; // mitarbeiter private gruppe var userId = User.Identity.GetUserId(); foreach (Lehrstuhl lehrstuhl in db.Lehrstuhls) { // Wenn der lehrstuhl privat ist, dann prüfe, ob User mitarbeiter ist // falls ja oder lehrstuhl nicht privat, dann OK und weiter (Admin sieht alles immer) // Signal an Frontend, ob User auch Verantwortlicher ist und somit bearbeiten/löschen darf verantwortlich[lehrstuhl.lehrstuhlid] = AuthCheck.VerantLehr(lehrstuhl.lehrstuhlid, userId); mitarbeiter[lehrstuhl.lehrstuhlid] = AuthCheck.MitarbeiterLehr(lehrstuhl.lehrstuhlid, userId); if (lehrstuhl.privat == true && !User.IsInRole("Admin")) { // hier werden PRIVATEN alle lehrstühle ausgeschlossen, in denen der User nicht Mitarbeiter ist ok = false; foreach (MitarbeiterLehrstuhl ml in db.MitarbeiterLehrstuhls) { if (ml.lehrstuhlid == lehrstuhl.lehrstuhlid && ml.userid == userId) { ok = true; } } } else { ok = true; } if (ok) { foreach (Person person in db.Person) { if (person.id == lehrstuhl.verantwortlicher) { lehrstuhl.verantwortlicher = HelpFunctions.GetDisplayName(person.id); // zuordnungstabelle für verlinkung erstellen Person el = new Person(); el.id = person.id; el.name = lehrstuhl.verantwortlicher; zuordnung.Add(el); } } entries.Add(lehrstuhl); } // Um abonnieren/deabonnieren zu kennzeichnen, ViewBag mit allen Abos des Users an Frontend senden List <AbonnentenLehrstuhl> list = new List <AbonnentenLehrstuhl>(); // Alle Abos des angemeldeten Users suchen foreach (AbonnentenLehrstuhl al in db.AbonnentenLehrstuhls) { if (al.userid == userId) { list.Add(al); } } ViewBag.abos = list; } ViewBag.mitarbeiter = mitarbeiter; ViewBag.verantwortlich = verantwortlich; ViewBag.zuordnung = zuordnung; return(View(entries)); }
public Person Get(AuthCheck request) { return PersonRepository.GetCurrent(); }
// Gibt eine Liste mit allen vorhandenen Gruppen zurück // Import: keine Importparameter // Export: View + vier ViewBags (zuordnung, verantwortlich, autor, beitritt) // GET: Gruppe public ActionResult Index() { List <Gruppe> entries = new List <Gruppe>(); List <Person> zuordnung = new List <Person>(); Boolean ok = false; // für prüfung auf mitgliedschaft Boolean[] verantwortlich = new Boolean[10000]; // Index gruppenid, Eintrag false -> Gruppe gruppenid kein Verantwortlicher Boolean[] mitglied = new Boolean[10000]; // Index gruppenid, Eintrag false -> Gruppe gruppenid kein mitglied foreach (Gruppe gruppe in db.Gruppes) { // Wenn die Gruppe privat ist, dann prüfe, ob User Mitglied der Gruppe ist // falls ja oder gruppe nicht privat, dann OK und weiter (Admin sieht alles immer) // Signal an Frontend, ob User auch Verantwortlicher ist und somit bearbeiten/löschen darf var userId = User.Identity.GetUserId(); verantwortlich[gruppe.gruppenid] = AuthCheck.VerantGr(gruppe.gruppenid, userId); mitglied[gruppe.gruppenid] = AuthCheck.MitgliedGr(gruppe.gruppenid, userId); if (gruppe.privat == true && !User.IsInRole("Admin")) { // hier werden PRIVATEN alle Gruppen ausgeschlossen, in denen der User nicht Mitglied ist ok = false; foreach (MitgliederGruppe mg in db.MitgliederGruppes) { if (mg.gruppenid == gruppe.gruppenid && mg.userid == userId) { ok = true; } } } else { ok = true; } if (ok) { foreach (Person person in db.Person) { if (person.id == gruppe.verantwortlicher) { gruppe.verantwortlicher = HelpFunctions.GetDisplayName(person.id); // zuordnungstabelle für verlinkung erstellen Person el = new Person(); el.id = person.id; el.name = gruppe.verantwortlicher; zuordnung.Add(el); } } entries.Add(gruppe); } // Um eintreten austreten zu kennzeichnen, ViewBag an frontend List <MitgliederGruppe> list = new List <MitgliederGruppe>(); // Alle mitgliedschaften des angemeldeten Users suchen foreach (MitgliederGruppe al in db.MitgliederGruppes) { if (al.userid == userId) { list.Add(al); } } ViewBag.beitritt = list; } ViewBag.zuordnung = zuordnung; ViewBag.verantwortlich = verantwortlich; ViewBag.mitglied = mitglied; return(View(entries)); }
public object Get(AuthCheck request) { return(IsLoggedIn); }