Commit 8256a487 authored by Marius Mauritz's avatar Marius Mauritz
Browse files

registrieren in db

parent e6c3d026
Pipeline #6281 passed with stage
in 3 minutes and 44 seconds
......@@ -51,7 +51,6 @@ class User extends Person {
Map<String, dynamic> toJson() => {
'id': id,
'contactCode': contactCode,
'username': username,
'surname': surname,
......
......@@ -20,7 +20,7 @@ class RegisterComponent implements OnInit, OnActivate {
RegisterComponent(this._registerService, this._router);
final Router _router;
final UserService _registerService;
final RegisterService _registerService;
User user = User.fromJson({
'id': null,
'contactCode': null,
......
......@@ -8,6 +8,7 @@ import 'package:demo/src/view/services/appointment_service.dart';
import 'package:demo/src/view/services/contact_service.dart';
import 'package:demo/src/view/services/dashboard_service.dart';
import 'package:demo/src/view/services/person_service.dart';
import 'package:demo/src/view/services/register_service.dart';
import 'components/login_component.dart';
......@@ -21,6 +22,7 @@ import 'components/login_component.dart';
ClassProvider(UserService),
ClassProvider(ContactService),
ClassProvider(DashboardService),
ClassProvider(RegisterService),
],
exports: [RoutePaths, Routes],
)
......
......@@ -69,10 +69,10 @@ class CalenderChannel extends ApplicationChannel {
router
.route('/appointments/lookup/[:year/[:month/[:day]]]')
.link(() => AppointmentController(context));
/*
router
.route('/user/[:number]')
.link(() => UserController(context));
/*
router
.route('/contacts/[:number]')
.link(() => ContactController(context));
......
/*
import 'dart:async';
import 'package:aqueduct/aqueduct.dart';
......@@ -61,4 +61,3 @@ class ContactController extends ResourceController {
return Response.ok(contactdelete);
}
}
*/
\ No newline at end of file
......@@ -11,18 +11,15 @@ class RegisterController extends ResourceController {
@Operation.post()
Future<Response> createUser(@Bind.body() User user) async {
print(user.toString());
// Check for required parameters before we spend time hashing
if (user.username == null || user.password == null ){
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
return Response.badRequest(
body: {"error": "username and password required."});
}
print("passiert#######################");
logger.warning("hier");
logger.warning(user.id);
user.salt = AuthUtility.generateRandomSalt();
user.hashedPassword = authServer.hashPassword(user.password, user.salt);
return Response.ok(await Query(context, values: user).insert());
}
}
......@@ -91,4 +91,5 @@ class UserController extends ResourceController {
int userdelete = await query.delete();
return Response.ok(userdelete);
}
}
\ No newline at end of file
}
import 'package:aqueduct/managed_auth.dart';
import 'package:middleman/middleman.dart';
......@@ -7,8 +8,31 @@ class User extends ManagedObject<_User> implements _User,ManagedAuthResourceOwne
String password;
}
class _User extends ResourceOwnerTableDefinition {
class Contact extends ManagedObject<_Contact> implements _Contact {}
class _Contact{
@Column(unique: false,nullable: true)
String note;
@primaryKey
int id;
@Column(unique: true, nullable: true)
String contactCode;
@Column(unique: false)
String surname;
@Column(unique: false)
String name;
@Column(unique: true)
String email;
}
class _User extends ResourceOwnerTableDefinition {
@Column(unique: false, nullable: true)
String mobileNo;
......@@ -25,3 +49,4 @@ class _User extends ResourceOwnerTableDefinition {
@Column(unique: true)
String email;
}
@override
Future seed() async {
final _appointments = [
{
"id": 1,
"name": "eins",
"year": 2019,
"month": 7,
"day": 22,
"time": "12:00",
"duration": "04:00",
"location": "Technischehochschule Lübeck",
"note": ""
},
{
"id": 2,
"name": "zwei",
"year": 2019,
"month": 5,
"day": 22,
"time": "12:00",
"duration": "04:00",
"location": "Technischehochschule Lübeck",
"note": ""
},
{
"id": 3,
"name": "drei",
"year": 2019,
"month": 5,
"day": 24,
"time": "12:00",
"duration": "04:00",
"location": "Technischehochschule Lübeck",
"note": ""
},
{
"id": 4,
"name": "vier",
"year": 2019,
"month": 5,
"day": 21,
"time": "12:00",
"duration": "04:00",
"location": "Technischehochschule Lübeck",
"note": ""
},
{
"id": 5,
"name": "fünf",
"year": 2019,
"month": 7,
"day": 22,
"time": "12:00",
"duration": "04:00",
"location": "Technischehochschule Lübeck",
"note": ""
},
];
final _contacts = [
{
"username": "marius",
"surname": "Marius",
"name": "Mauritz",
"email": "hallo@hallo.gmx.de",
"contactCode": "ContactCode1",
"note": "Datenbank experte"
},
{
"username": "lauri",
"surname": "Laurenz",
"name": "Schindler",
"email": "hello@world.gmx.de",
"contactCode": "ContactCode2",
"note": "voll der pro"
}
];
final _users = [
{
"username": "dude2",
"surname": "drei",
"name": "vier",
"email": "hello@hello.gmx.de",
"contactCode": "12345",
"password": "Calendar123",
"mobileNo": ""
}];
_appointments.forEach((Map<String, dynamic> map) async =>
await database.store.execute(
"INSERT INTO _Appointment (name,time,year,month,day,duration,location,note) VALUES (@name,@time,@year,@month,@day,@duration,@location,@note)",
substitutionValues: {
"name": map['name'],
"time": map['time'],
"year": map['year'],
"month": map['month'],
"day": map['day'],
"duration": map['duration'],
"location": map['location'],
"note": map['note']
}));
_contacts.forEach((Map<String, String> map) async =>
await database.store.execute(
"INSERT INTO _Contact (username,surname,name,email,contactCode,note) VALUES (@username,@surname,@name,@email,@contactCode,@note)",
substitutionValues: {
"username": map['username'],
"surname": map['surname'],
"name": map['name'],
"email": map['email'],
"contactCode": map['contactCode'],
"note": map['note']
}));
_users.forEach((Map<String, String> map) async =>
await database.store.execute(
"INSERT INTO _User (username,surname,name,email,contactCode,password,mobileNo) VALUES (@username,@surname,@name,@email,@contactCode,@password,@mobileNo)",
substitutionValues: {
"username": map['username'],
"surname": map['surname'],
"name": map['name'],
"email": map['email'],
"contactCode": map['contactCode'],
"password": map['password'],
"mobileNo": map['mobileNo']
}));
}
__
@override
Future seed() async {
......@@ -191,25 +60,6 @@ __
},
];
final _contacts = [
{
"username": "marius",
"surname": "Marius",
"name": "Mauritz",
"email": "hallo@hallo.gmx.de",
"contactCode": "ContactCode1",
"note": "Datenbank experte"
},
{
"username": "lauri",
"surname": "Laurenz",
"name": "Schindler",
"email": "hello@world.gmx.de",
"contactCode": "ContactCode2",
"note": "voll der pro"
}
];
final _users = [
{
"password": "dude2",
......@@ -237,18 +87,6 @@ __
"note": map['note']
}));
_contacts.forEach((Map<String, String> map) async =>
await database.store.execute(
"INSERT INTO _Contact (username,surname,name,email,contactCode,note) VALUES (@username,@surname,@name,@email,@contactCode,@note)",
substitutionValues: {
"username": map['username'],
"surname": map['surname'],
"name": map['name'],
"email": map['email'],
"contactCode": map['contactCode'],
"note": map['note']
}));
_users.forEach((Map<String, String> map) async =>
await database.store.execute(
"INSERT INTO _User (username,surname,name,email,contactCode,hashedPassword,mobileNo,salt) VALUES (@username,@surname,@name,@email,@contactCode,@hashedPassword,@mobileNo,@salt)",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment