From b44d180284725b528acebc56c6747bda60f9fac9 Mon Sep 17 00:00:00 2001 From: LilleBRG Date: Mon, 26 Aug 2024 09:42:17 +0200 Subject: [PATCH] profile partly done. added scrolling on login and register page --- API/API.csproj.user | 2 +- API/Application/Users/Commands/LoginUser.cs | 4 +- .../Users/Queries/QueryUserById.cs | 9 +- Mobile/lib/login.dart | 4 +- Mobile/lib/main.dart | 2 - Mobile/lib/register.dart | 90 ++++++++++--------- 6 files changed, 55 insertions(+), 56 deletions(-) diff --git a/API/API.csproj.user b/API/API.csproj.user index 880bcb5..4dbcfbc 100644 --- a/API/API.csproj.user +++ b/API/API.csproj.user @@ -1,7 +1,7 @@  - https + http ApiControllerWithContextScaffolder root/Common/Api 650 diff --git a/API/Application/Users/Commands/LoginUser.cs b/API/Application/Users/Commands/LoginUser.cs index 2659503..21b52f5 100644 --- a/API/Application/Users/Commands/LoginUser.cs +++ b/API/Application/Users/Commands/LoginUser.cs @@ -29,9 +29,9 @@ namespace API.Application.Users.Commands { return new UnauthorizedObjectResult(new { message = "Invalid email or password." }); } - var token = GenerateJwtToken(user); + var jwtToken = GenerateJwtToken(user); - return new OkObjectResult(token); + return new OkObjectResult(new { token = jwtToken, id = user.Id}); } diff --git a/API/Application/Users/Queries/QueryUserById.cs b/API/Application/Users/Queries/QueryUserById.cs index def7b62..d3a6d6b 100644 --- a/API/Application/Users/Queries/QueryUserById.cs +++ b/API/Application/Users/Queries/QueryUserById.cs @@ -2,6 +2,7 @@ using API.Persistence.Repositories; using Microsoft.AspNetCore.Mvc; using Microsoft.VisualStudio.Web.CodeGenerators.Mvc.Templates.BlazorIdentity.Pages.Manage; +using Newtonsoft.Json.Linq; namespace API.Application.Users.Queries { @@ -23,14 +24,8 @@ namespace API.Application.Users.Queries return new ConflictObjectResult(new { message = "No user on given Id" }); } - UserDTO userDTO = new UserDTO - { - Id = user.Id, - Email = user.Email, - Username = user.Username - }; + return new OkObjectResult(new { id = user.Id, email = user.Email, username = user.Username, createdAt = user.CreatedAt }); - return userDTO; } } diff --git a/Mobile/lib/login.dart b/Mobile/lib/login.dart index 7c8b3fa..a2fee40 100644 --- a/Mobile/lib/login.dart +++ b/Mobile/lib/login.dart @@ -49,7 +49,8 @@ class _LoginPageState extends State { return SideMenu( selectedIndex: 4, body: Scaffold( - body: Center( + body: SingleChildScrollView( + child: Center( child: Container( constraints: const BoxConstraints(minWidth: 100, maxWidth: 400), child: Column(children: [ @@ -86,6 +87,7 @@ class _LoginPageState extends State { ]), ), ), + ), ), ); } diff --git a/Mobile/lib/main.dart b/Mobile/lib/main.dart index 710327a..77b6b00 100644 --- a/Mobile/lib/main.dart +++ b/Mobile/lib/main.dart @@ -1,6 +1,4 @@ import 'dart:convert'; -import 'dart:developer'; - import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:latlong2/latlong.dart'; diff --git a/Mobile/lib/register.dart b/Mobile/lib/register.dart index ca5feb6..b8156e9 100644 --- a/Mobile/lib/register.dart +++ b/Mobile/lib/register.dart @@ -37,17 +37,19 @@ class _RegisterPageState extends State { } @override - Widget build(BuildContext context) { - return SideMenu( - selectedIndex: 3, - body: Scaffold( - body: Center( +Widget build(BuildContext context) { + return SideMenu( + selectedIndex: 3, + body: Scaffold( + body: SingleChildScrollView( + child: Center( // Added SingleChildScrollView here child: Container( constraints: const BoxConstraints(minWidth: 100, maxWidth: 400), - child: Column(children: [ - const Image( - image: AssetImage('assets/logo.png'), - height: 200, + child: Column( + children: [ + const Image( + image: AssetImage('assets/logo.png'), + height: 200, ), Text( 'SkanTravels', @@ -56,43 +58,45 @@ class _RegisterPageState extends State { color: Color(0xFF1862E7), ), ), - const SizedBox(height: 40), - const Text('Username'), - TextField(controller: usernameInput), - const SizedBox(height: 30), - const Text('Email'), - TextField(controller: emailInput), - const SizedBox(height: 30), - const Text('Password'), - TextField( - controller: passwordInput, - obscureText: true, - enableSuggestions: false, - autocorrect: false - ), - const SizedBox(height: 30), - const Text('Confirm Password'), - TextField( - controller: confirmPasswordInput, - obscureText: true, - enableSuggestions: false, - autocorrect: false, - ), - const SizedBox(height: 30), - - ElevatedButton( - onPressed: _register, child: const Text('Register')), - const SizedBox(height: 10), - const Text('or'), - TextButton( - child: const Text('Login'), - onPressed: () => Navigator.pushReplacementNamed(context, '/login')), - ]), + const SizedBox(height: 40), + const Text('Username'), + TextField(controller: usernameInput), + const SizedBox(height: 30), + const Text('Email'), + TextField(controller: emailInput), + const SizedBox(height: 30), + const Text('Password'), + TextField( + controller: passwordInput, + obscureText: true, + enableSuggestions: false, + autocorrect: false + ), + const SizedBox(height: 30), + const Text('Confirm Password'), + TextField( + controller: confirmPasswordInput, + obscureText: true, + enableSuggestions: false, + autocorrect: false, + ), + const SizedBox(height: 30), + ElevatedButton( + onPressed: _register, child: const Text('Register')), + const SizedBox(height: 10), + const Text('or'), + TextButton( + child: const Text('Login'), + onPressed: () => Navigator.pushReplacementNamed(context, '/login')), + ], + ), ), ), ), - ); - } + ), + ); +} + @override void dispose() {