Update 20210528 - mit LoginPopup

master
Stefan Hutter 5 years ago
parent 5dcd0d1046
commit a437ae0be4

File diff suppressed because it is too large Load Diff

Binary file not shown.

@ -5,7 +5,9 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" /> <PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.15" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.15" />
<PackageReference Include="Syncfusion.EJ2.AspNet.Core" Version="19.1.0.64" /> <PackageReference Include="Microsoft.AspNetCore.Session" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.5" />
<PackageReference Include="Syncfusion.EJ2.AspNet.Core" Version="19.1.0.54" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="BWPMModels"> <Reference Include="BWPMModels">

@ -3,7 +3,12 @@
<PropertyGroup> <PropertyGroup>
<Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID> <Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID>
<Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath> <Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
<View_SelectedScaffolderID>RazorViewEmptyScaffolder</View_SelectedScaffolderID> <View_SelectedScaffolderID>RazorViewScaffolder</View_SelectedScaffolderID>
<View_SelectedScaffolderCategoryPath>root/Common/MVC/View</View_SelectedScaffolderCategoryPath> <View_SelectedScaffolderCategoryPath>root/Common/MVC/View</View_SelectedScaffolderCategoryPath>
<WebStackScaffolding_ViewDialogWidth>650</WebStackScaffolding_ViewDialogWidth>
<WebStackScaffolding_IsLayoutPageSelected>True</WebStackScaffolding_IsLayoutPageSelected>
<WebStackScaffolding_IsPartialViewSelected>True</WebStackScaffolding_IsPartialViewSelected>
<WebStackScaffolding_IsReferencingScriptLibrariesSelected>False</WebStackScaffolding_IsReferencingScriptLibrariesSelected>
<WebStackScaffolding_LayoutPageFile />
</PropertyGroup> </PropertyGroup>
</Project> </Project>

@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace sf1.Controllers namespace App.Controllers
{ {
public class FormController : Controller public class FormController : Controller
{ {

@ -5,9 +5,9 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using sf1.Models; using App.Models;
namespace sf1.Controllers namespace App.Controllers
{ {
public class HomeController : Controller public class HomeController : Controller
{ {

@ -0,0 +1,37 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using APP.Models;
namespace APP.Controllers
{
public class LoginController : Controller
{
public IActionResult Index()
{
return View();
}
public IActionResult Login(LoginModel model)
{
App.Helper.HttpClientHelper httpcli = new App.Helper.HttpClientHelper();
string username = model.UserName;
string password = model.Password;
httpcli.CallService("user",username+','+password, "GET", null);
if (httpcli.Results.resultstatus==true && httpcli.Results.daten !="[]")
{
APP.Models.SessionClass.UserName = "AAA";
return Json(new { success = true });
}
else
{
return Json(new { error = "Kann nicht angemeldet werden!" });
};
return Json(new { error = "" });
}
}
}

@ -10,20 +10,18 @@ using Syncfusion.EJ2;
using BWPMModels; using BWPMModels;
using System.Collections; using System.Collections;
using Syncfusion.EJ2.Base; using Syncfusion.EJ2.Base;
using sf1.Models;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Reflection; using System.Reflection;
using App.Models;
namespace sf1.Controllers namespace App.Controllers
{ {
public partial class UserController : Controller public partial class UserController : Controller
{ {
private const string URL = "http://localhost/CoreWebAPI1/api/";
public IActionResult Index() public IActionResult Index()
{ {
return View(); return View();
} }
@ -85,8 +83,6 @@ namespace sf1.Controllers
Helper.HttpClientHelper httpcli = new Helper.HttpClientHelper(); Helper.HttpClientHelper httpcli = new Helper.HttpClientHelper();
User u = new User(); User u = new User();
u = value.value; u = value.value;
u.Teststring = "hallo";
u.aktiv = true;
httpcli.CallService("user", "", "POST", u); httpcli.CallService("user", "", "POST", u);
if (httpcli.Results.resultstatuscode != "OK") if (httpcli.Results.resultstatuscode != "OK")
{ {
@ -109,5 +105,7 @@ namespace sf1.Controllers
} }
} }
} }

@ -1,16 +1,16 @@
using MyModels; using BWPMModels;
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Net.Http;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Net.Http.Formatting; using System.Net.Http.Formatting;
using System.Threading.Tasks; using System.Threading.Tasks;
using sf1.Models; using App.Models;
namespace sf1.Helper namespace App.Helper
{ {
public class HttpClientHelper public class HttpClientHelper
{ {
@ -60,6 +60,7 @@ namespace sf1.Helper
Results.daten = readTask.Result; Results.daten = readTask.Result;
break; break;
} }
break; break;

@ -1,15 +1,15 @@
using Microsoft.Extensions.Configuration; using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace sf1.Helper namespace App.Helper
{ {
public class ParameterHelper public class ParameterHelper
{ {
public string GetParameter(string Keyvalue) public string GetParameter(string Keyvalue)
{ {
var configuation = GetConfiguration(); var configuation = GetConfiguration();
@ -22,4 +22,8 @@ namespace sf1.Helper
return builder.Build(); return builder.Build();
} }
} }
} }

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace sf1.Models namespace App.Models
{ {
public class ICRUDModel<T> where T : class public class ICRUDModel<T> where T : class
{ {

@ -1,6 +1,6 @@
using System; using System;
namespace sf1.Models namespace App.Models
{ {
public class ErrorViewModel public class ErrorViewModel
{ {

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace APP.Models
{
public class LoginModel
{
public string UserName { get; set; }
public string Password { get; set; }
}
}

@ -0,0 +1,61 @@

using Microsoft.AspNetCore.Http;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using BWPMModels;
namespace App.Models
{
public class AppMenuItem
{
public string id { get; set; }
public string text { get; set; }
public string parentId { get; set; }
public string url { get; set; }
//public static List<AppMenuItem> MenuItems(string usertype)
public static List<object> MenuItems(string usertype)
{
Helper.HttpClientHelper httpcli = new Helper.HttpClientHelper();
httpcli.CallService("MenuItem", APP.Models.SessionClass.UserType, "GET", null);
if (httpcli.Results.resultstatus == true)
{
List<object> mis = new List<object>();
List<BWPMModels.MenuItem> menus = JsonConvert.DeserializeObject<List<BWPMModels.MenuItem>>(httpcli.Results.daten);
//List<AppMenuItem> mis = new List<AppMenuItem>();
//mis.Add (new AppMenuItem { id = "1", text = "Text 1", parentId = "", url = "Home" });
//mis.Add(new AppMenuItem { id = "2", text = "Text 2", parentId = "1", url = "Form" });
//mis.Add(new AppMenuItem { id = "3", text = "Text3", parentId = "null", url = "" });
//return mis;
foreach (BWPMModels.MenuItem item in menus)
{
mis.Add(new AppMenuItem { id = item.ID, text = item.text, parentId = item.parentId, url = item.url });
}
if (APP.Models.SessionClass.UserName == "")
{
mis.Add(new AppMenuItem { id = "999", text = "Login" , parentId = "", url = "Login"});
}
return mis;
}
//ViewBag.DataSource = users;
//menus.Add(new MenuItem { id = "1", text = "Text 1", parentId = "", url="Home" });
//menus.Add(new MenuItem { id = "2", text = "Text 2", parentId = "1", url="Form"});
//menus.Add(new MenuItem { id = "3", text = "Text3", parentId = "null",url="" });
return null;
}
}
}

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace APP.Models
{
public static class SessionClass
{
public static string UserType { get; set; } = "0";
public static string UserName { get; set; } = "";
public static void SetSessionValue()
{
UserType = "1";
}
}
}

@ -20,6 +20,7 @@ namespace sf1
{ {
public class Startup public class Startup
{ {
public Startup(IConfiguration configuration) public Startup(IConfiguration configuration)
{ {
Configuration = configuration; Configuration = configuration;
@ -35,12 +36,23 @@ namespace sf1
{ {
options.SerializerSettings.ContractResolver = new DefaultContractResolver(); options.SerializerSettings.ContractResolver = new DefaultContractResolver();
}); });
services.AddDistributedMemoryCache();
services.AddSession(options =>
{
options.IdleTimeout= TimeSpan.FromSeconds(60);
options.Cookie.Name = ".bwpm.Session";
options.Cookie.IsEssential = true;
});
APP.Models.SessionClass.SetSessionValue();
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{ {
if (env.IsDevelopment()) if (env.IsDevelopment())
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
@ -57,6 +69,7 @@ namespace sf1
app.UseRouting(); app.UseRouting();
app.UseAuthorization(); app.UseAuthorization();
app.UseSession();
app.UseEndpoints(endpoints => app.UseEndpoints(endpoints =>
{ {

@ -0,0 +1,34 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
//using App.Models;
using Microsoft.AspNetCore.Http;
using BWPMModels;
using App.Models;
namespace APP.ViewComponents
{
public class MenuItemsViewComponent : ViewComponent
{
List<Object> menuItems = new List<Object>();
//List<AppMenuItem> menuItems = new List<AppMenuItem>();
public MenuItemsViewComponent()
{
//HttpContext.Session.SetString("usertype","1");
//string usertype = HttpContext.Session.GetString("usertype");
menuItems = AppMenuItem.MenuItems(APP.Models.SessionClass.UserType);
ViewBag.menuitems = menuItems;
var model = menuItems;
}
public async Task<IViewComponentResult> InvokeAsync()
{
var model = menuItems;
ViewBag.menuitems = menuItems;
return await Task.FromResult((IViewComponentResult)View("MenuItems", model));
}
}
}

@ -0,0 +1,5 @@
@{
ViewData["Title"] = "Error";
}
<ejs-menu id="menu" items="ViewBag.menuItems"></ejs-menu>

@ -0,0 +1,5 @@
@{
ViewData["Title"] = "Error";
}
Ich bin der User-Status

@ -1,4 +1,9 @@
<!DOCTYPE html> @using Syncfusion.EJ2
@model APP.Models.LoginModel
@{
var defaultanimation = new Syncfusion.EJ2.Popups.DialogAnimationSettings { Effect = Syncfusion.EJ2.Popups.DialogEffect.Zoom };
}
<!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
@ -7,38 +12,101 @@
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" /> <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" /> <link rel="stylesheet" href="~/css/site.css" />
<link rel="stylesheet" href="~/css/ej2/bootstrap.css" /> <link rel="stylesheet" href="~/css/ej2/bootstrap.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="~/js/ej2/ej2.min.js"></script> <script src="~/js/ej2/ej2.min.js"></script>
</head> </head>
<body> <body>
<header> <header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3"> <nav class="navbar navbar-dark navbar-expand-lg fixed-top bg-white portfolio-navbar gradient">
<div class="container"> <div class="container">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">sf1</a> <a class="navbar-brand logo" href="#">BWPM</a><button data-bs-toggle="collapse" class="navbar-toggler" data-bs-target="#navbarNav"><span class="visually-hidden">Toggle navigation</span><span class="navbar-toggler-icon"></span></button>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent" <div class="collapse navbar-collapse" id="navbarNav">
aria-expanded="false" aria-label="Toggle navigation"> @(await Component.InvokeAsync("MenuItems"))
<span class="navbar-toggler-icon"></span> @*<ul class="navbar-nav ms-auto">
</button> <li class="nav-item"><a class="nav-link active" href="index.html">Home</a></li>
<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse"> <li class="nav-item"><a class="nav-link" href="projects-grid-cards.html">Projects</a></li>
<ul class="navbar-nav flex-grow-1"> <li class="nav-item"><a class="nav-link" href="cv.html">CV</a></li>
<li class="nav-item"> <li class="nav-item"><a class="nav-link" href="hire-me.html">Hire me</a></li>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a> </ul>*@
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</li>
</ul>
</div> </div>
</div> </div>
<button id="btnclick" type="button">Login</button>
</nav> </nav>
</header> </header>
<style>
.popup {
position: absolute;
margin: auto;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 500px;
height: 400px;
}
</style>
<div id="mycontainer" class="popup" style="display:none">
<ejs-dialog id="default_dialog" width="500px" target="#mycontainer" showCloseIcon="true" header="Berufwahl-Parcours-Manager Login">
<e-content-template>
<form method="post" action="/Login/login">
<div class="col-12 form-item">
<input class="e-input" placeholder="UserName" name="UserName">
</div>
<div class="col-12 form-item">
<div class="e-input-group">
<input class="e-input" placeholder="Password" type="password" name="password">
</div>
</div>
<div style="text-align: center">
<button class="e-btn" type="submit"> Login </button>
</div>
</form>
</e-content-template>
</ejs-dialog>
</div>
<script>
window.onload = function () {
document.getElementById('btnclick').onclick = function () {
var cont = document.getElementById("mycontainer");
cont.style.display = "block";
var dialog = document.getElementById("default_dialog").ej2_instances[0];
dialog.show();
}
}
document.getElementById('sendButton').onclick = function (e) {
}
</script>
<script type="text/javascript">
$('form').submit(function (e) {
e.preventDefault();
$.post(this.action, $(this).serialize(), function (response) {
if (response.error) {
alert(response.error);
}
else {
var dialog = document.getElementById("default_dialog").ej2_instances[0];
dialog.hide();
}
}, 'json');
});
</script>
<div class="container"> <div class="container">
<main role="main" class="pb-3"> <main role="main" class="pb-3">
@RenderBody() @RenderBody()
</main> </main>
</div> </div>
<footer class="border-top footer text-muted"> <footer class="border-top footer text-muted">
<div class="container"> <div class="container">
&copy; @DateTime.Now.Year - sf1 - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a> &copy; @DateTime.Now.Year - sf1 - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>

@ -0,0 +1,14 @@
@{
var ut = APP.Models.SessionClass.UserName;
string funktion = "";
if (ut == "")
{
@:Login
}
else
{
@:Logout
}
}

@ -1,4 +1,4 @@
@using sf1 @using App
@using sf1.Models @using App.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Syncfusion.EJ2 @addTagHelper *, Syncfusion.EJ2

@ -1,4 +1,3 @@
@{ @{
Layout = "_Layout"; Layout = "_Layout";
} }
gaga

@ -7,7 +7,7 @@
} }
}, },
"AppSettings": { "AppSettings": {
"API": "http://localhost/CoreWebAPI1/api/", "API": "http://localhost:10603/api/",
"ApiKey": "BgWSbwCNM3pEiCxgIlDEyD7HFpUgKPeL8OPDqH9n" "ApiKey": "BgWSbwCNM3pEiCxgIlDEyD7HFpUgKPeL8OPDqH9n"
}, },
"AllowedHosts": "*" "AllowedHosts": "*"

File diff suppressed because it is too large Load Diff

@ -0,0 +1,9 @@
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\Steafn Hutter lokal\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\Steafn Hutter lokal\\.nuget\\packages",
"C:\\Program Files (x86)\\Microsoft\\Xamarin\\NuGet"
]
}
}

@ -0,0 +1,13 @@
{
"runtimeOptions": {
"tfm": "netcoreapp3.1",
"framework": {
"name": "Microsoft.AspNetCore.App",
"version": "3.1.0"
},
"configProperties": {
"System.GC.Server": true,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

@ -0,0 +1,15 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AppSettings": {
"API": "http://localhost:10603/api/",
"ApiKey": "BgWSbwCNM3pEiCxgIlDEyD7HFpUgKPeL8OPDqH9n"
},
"AllowedHosts": "*"
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save