Commit 1c14e01a authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

register + bugs

parent 516317e1
......@@ -168,7 +168,7 @@ export class BoilerplateListComponent implements OnInit {
this.boilerplateService.getAllInfer(this.route.snapshot.params.gb)
.subscribe(
data => {
console.log(data);
//console.log(data);
this.currentInfer = data[0];
this.infer = data;
if (data[0]) {
......@@ -235,7 +235,9 @@ export class BoilerplateListComponent implements OnInit {
}
getincreq(): any {
return this.get_metrics('IncompleteRequirement').length;
if(this.get_metrics('IncompleteRequirement').length>0){
return this.get_metrics('IncompleteRequirement').length;}
else return 0;
}
}
......@@ -2,6 +2,7 @@
width: 350px;
height: 250px;
margin-right: 5px;
margin-top: 10px;
}
.mat-card-content{
height: 100px;
......
......@@ -37,7 +37,7 @@
<button mat-stroked-button color="primary" class="btn-block" type="submit" (click)="login(email.value, password.value)" >Log in</button>
<!-- Register -->
<p>Not a member?
<a href="#">Register</a>
<a mat-menu-item (click)="btnRegister()">Register</a>
</p>
</form>
</mat-card>
......
......@@ -40,4 +40,9 @@ export class LoginComponent implements OnInit {
);
}
btnRegister () {
this.router.navigate(['signup']);
}
}
<div style="text-align:center">
<h1>
Signup
</h1>
</div>
<input #username type='text' placeholder='username'>
<input #email type='text' placeholder='email'>
<input #password1 type='password' placeholder='password1'>
<input #password2 type='password' placeholder='password2'>
<button (click)="signup(username.value, email.value, password1.value, password2.value)">signup</button>
<p>{{ error?.message }}</p>
<p *ngIf="error">{{ error?.error | json }}</p>
\ No newline at end of file
<div *ngIf='this.sended' class="alert alert-success" role="alert">Your details have been registered and you will be notified when the user account will be activated</div>
<div class="main-wrapper" margin fxLayout="row" fxLayoutAlign="center center">
<mat-card class="box">
<form [formGroup]="form" (ngSubmit)="onSubmit()">
<div class="form-group">
<label>Full Name</label>
<input
type="text"
formControlName="fullname"
class="form-control"
[ngClass]="{ 'is-invalid': submitted && f.fullname.errors }"
/>
<div *ngIf="submitted && f.fullname.errors" class="invalid-feedback">
<div *ngIf="f.fullname.errors.required">Fullname is required</div>
</div>
</div>
<div class="form-group">
<label>Username</label>
<input
type="text"
formControlName="username"
class="form-control"
[ngClass]="{ 'is-invalid': submitted && f.username.errors }"
/>
<div *ngIf="submitted && f.username.errors" class="invalid-feedback">
<div *ngIf="f.username.errors.required">Username is required</div>
<div *ngIf="f.username.errors.minlength">
Username must be at least 6 characters
</div>
<div *ngIf="f.username.errors.maxlength">
Username must not exceed 20 characters
</div>
</div>
</div>
<div class="form-group">
<label>Email</label>
<input
type="text"
formControlName="email"
class="form-control"
[ngClass]="{ 'is-invalid': submitted && f.email.errors }"
/>
<div *ngIf="submitted && f.email.errors" class="invalid-feedback">
<div *ngIf="f.email.errors.required">Email is required</div>
<div *ngIf="f.email.errors.email">Email is invalid</div>
</div>
</div>
<div class="form-group">
<label>Password</label>
<input
type="password"
formControlName="password"
class="form-control"
[ngClass]="{ 'is-invalid': submitted && f.password.errors }"
/>
<div *ngIf="submitted && f.password.errors" class="invalid-feedback">
<div *ngIf="f.password.errors.required">Password is required</div>
<div *ngIf="f.password.errors.minlength">
Password must be at least 8 characters
</div>
<div *ngIf="f.password.errors.maxlength">
Username must not exceed 40 characters
</div>
</div>
</div>
<div class="form-group">
<label>Confirm Password</label>
<input
type="password"
formControlName="confirmPassword"
class="form-control"
[ngClass]="{ 'is-invalid': submitted && f.confirmPassword.errors }"
/>
<div
*ngIf="submitted && f.confirmPassword.errors"
class="invalid-feedback"
>
<div *ngIf="f.confirmPassword.errors.required">
Confirm Password is required
</div>
<div *ngIf="f.confirmPassword.errors.matching">
Confirm Password does not match
</div>
</div>
</div>
<div class="form-group form-check">
<input
type="checkbox"
formControlName="acceptTerms"
class="form-check-input"
[ngClass]="{ 'is-invalid': submitted && f.acceptTerms.errors }"
/>
<label for="acceptTerms" class="form-check-label" matTooltip="Your data will be shared with the team, in order to verify your account." matTooltipPosition="right"
>I have read and agree to the Terms</label
>
<div *ngIf="submitted && f.acceptTerms.errors" class="invalid-feedback" >
Accept Terms is required
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary" [disabled]='this.sended'>Register</button>
<button
type="button"
(click)="onReset()"
class="btn btn-warning float-right"
>
Reset
</button>
</div>
</form>
</mat-card>
</div>
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { AuthService } from './../../services/auth.service';
import { NotifierService } from "angular-notifier";
import { AbstractControl, FormBuilder, FormGroup, Validators, ValidatorFn } from '@angular/forms';
@Component({
selector: 'app-signup',
templateUrl: './singup.component.html',
styleUrls: ['./singup.component.scss']
})
export class SignupComponent implements OnInit {
export class SignupComponent implements OnInit {
private readonly notifier: NotifierService;
constructor(
private authService: AuthService,
private router: Router,
notifierService: NotifierService,
private formBuilder: FormBuilder) {this.notifier = notifierService;}
form = new FormGroup({});
submitted = false;
sended = false;
ngOnInit(): void {
this.form = this.formBuilder.group(
{
fullname: ['', Validators.required],
username: [
'',
[
Validators.required,
Validators.minLength(6),
Validators.maxLength(20)
]
],
email: ['', [Validators.required, Validators.email]],
password: [
'',
[
Validators.required,
Validators.minLength(8),
Validators.maxLength(40)
]
],
confirmPassword: ['', Validators.required],
acceptTerms: [false, Validators.requiredTrue]
},
{
validators: [this.match('password', 'confirmPassword')]
}
);
}
error: any;
match(controlName: string, checkControlName: string): ValidatorFn {
return (controls: AbstractControl) => {
const control = controls.get(controlName);
const checkControl = controls.get(checkControlName);
if (checkControl?.errors && !checkControl.errors.matching) {
return null;
}
if (control?.value !== checkControl?.value) {
controls.get(checkControlName)?.setErrors({ matching: true });
return { matching: true };
} else {
return null;
}
};
}
constructor() { }
ngOnInit() {
get f(): { [key: string]: AbstractControl } {
return this.form.controls;
}
onSubmit(): void {
this.submitted = true
if (this.form.invalid) {
//this.notifier.notify("warning",(JSON.stringify("Invalid form")));
return;
}
this.onSign();
//console.log(JSON.stringify(this.form.value, null, 2));
}
onReset(): void {
this.submitted = false;
this.sended = false;
this.form.reset();
}
signup(username: string, email: string, password1: string, password2: string) {
// TODO: call signup
onSign (){
this.authService.signup(this.form.value.fullname, this.form.value.username, this.form.value.email, this.form.value.password, this.form.value.confirmPassword).subscribe(
success => {console.log('SUCCESS');},
error => {console.log(error.statusText);
if (error.statusText == 'OK') {this.sended = true}
else{this.notifier.notify("warning",(JSON.stringify("There might be a problem with your registration. Please try again later.")));}
}
);
}
}
<mat-nav-list>
<a mat-list-item routerLink="#" (click)="onSidenavClose()">
<mat-icon>home</mat-icon> <span class="nav-caption">Home</span>
<a mat-list-item (click)="LogOut()">
<mat-icon>logout</mat-icon> <span class="nav-caption">Log out</span>
</a>
<a mat-list-item routerLink="#" (click)="onSidenavClose()">
<!-- <a mat-list-item routerLink="#" (click)="onSidenavClose()">
<mat-icon>assignment_ind</mat-icon> <span class="nav-caption">Owner Actions</span>
</a>
<a mat-list-item routerLink="#" (click)="onSidenavClose()">
......@@ -15,5 +15,5 @@
<mat-menu #menu="matMenu">
<button mat-menu-item (click)="onSidenavClose()">View profile</button>
<button mat-menu-item (click)="onSidenavClose()">Add contact</button>
</mat-menu>
</mat-menu> -->
</mat-nav-list>
\ No newline at end of file
import { Component, OnInit, Output, EventEmitter } from '@angular/core';
import { AuthService } from './../../services/auth.service';
@Component({
selector: 'app-sidenav-list',
......@@ -8,10 +9,14 @@ import { Component, OnInit, Output, EventEmitter } from '@angular/core';
export class SidenavListComponent implements OnInit {
@Output() sidenavClose = new EventEmitter();
constructor() { }
constructor(private authService: AuthService){}
ngOnInit() {
}
public onSidenavClose = () => {
this.sidenavClose.emit();
}
LogOut() {
return this.authService.logout();
}
}
......@@ -17,6 +17,8 @@ import { environment } from '../../environments/environment';
export class AuthService {
private apiRoot = environment.apiroot +'auth/';
private baseUrlgb = environment.apiroot+'api-auth/signup/'
constructor(private http: HttpClient, private router:Router) { }
......@@ -45,8 +47,16 @@ export class AuthService {
);
}
signup(username: string, email: string, password1: string, password2: string) {
// TODO: implement signup
signup(fullname: string, username: string, email: string, password1: string, password2: string) {
return this.http.post(
this.baseUrlgb,
{ fullname, email, username, password1 }
).pipe(
//tap(response => this.setSession(response)),
tap(response => console.log(response)),
);
}
logout() {
......
This diff is collapsed.
......@@ -12,6 +12,7 @@ from reqman.apps.reqtool.rest_api.services.parse_ontologies import *
from pygments.formatters.html import HtmlFormatter
from pygments import highlight
from subprocess import call
from reqman.settings.environment import env
#get prefix syntax from the Onotlogy#
......@@ -85,15 +86,14 @@ def create_infer_result(instance, destination):
def initialize_instances(instance):
try :
g = Graph()
print(instance.ontology_file)
file_name = instance.title_bgroup.replace('/', '')
save_path = "../../Ontologies/"+file_name+"/"
if (os.path.exists("../../Ontologies/"+file_name+"/") == False):
os.mkdir("../../Ontologies/"+file_name)
completeName = os.path.join(save_path, file_name)
if (instance.ontology_file != '../../Ontologies/Default'):
ont = instance.ontology_file.replace('../../Ontologies/', '')
call("./../../Ontologies/s-get http://155.207.131.19:3030/"+ont+" default >> ../../Ontologies/"+file_name+'/'+file_name+'.ttl', shell=True)
ont = instance.ontology_file.replace('../../Ontologies', '')
call("./../../Ontologies/s-get "+ env("FUSEKI_URL")+ ont +" default >> ../../Ontologies/"+file_name+'/'+file_name+'.ttl', shell=True)
destination=save_path+file_name+'.ttl'
else :
g.load('../../Ontologies/2022_AOCS.ttl', format="turtle")
......
......@@ -4,8 +4,6 @@ from rdflib import ConjunctiveGraph, URIRef, RDFS, RDF, Namespace, Literal
#from subprocess import call
#call("./../../Ontologies/s-get http://155.207.131.19:3030/Mokos_18_1_7_47/data default >> ../../Ontologies/data.ttl", shell=True)
#HERE
#list_of_DSO = ["http://delab.csd.auth.gr/ontologies/2018/SAO#","http://delab.csd.auth.gr/ontologies/2018/DSO#", "http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive#", "http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive-AVP#", "http://delab.csd.auth.gr/ontologies/2018/DSO-Automotive-AVP-instances#","http://delab.csd.auth.gr/ontologies/2018/RDO-instances#"]
list_of_DSO = []
......
......@@ -5,6 +5,7 @@ from django.conf.urls import url
from .views import user_views, requirements_views, main_req_views, suffix_req_views
urlpatterns = [
url(r'^signup/$', user_views.signup, name='signup'),
path('users/', user_views.UserList.as_view(), name='api-user-list'),
path('users/<uuid:pk>/', user_views.UserDetail.as_view(), name='api-post-details'),
path('ontologies/', requirements_views.OntologiesChoicesViewSet.as_view(), name='api-get-ontologies'),
......
......@@ -34,7 +34,7 @@ class OntologiesChoicesViewSet(APIView):
def get(self, request):
data={'datasets':''}
try :
url = requests.get(env("FUSEKI_URL")+"/$/datasets", auth = HTTPBasicAuth('admin', 'pw!!!'))
url = requests.get(env("FUSEKI_URL")+"/$/datasets", auth = HTTPBasicAuth(env("FUSEKI_Username"), env("FUSEKI_Password")))
text = url.text
data = json.loads(text)
except:
......
......@@ -2,6 +2,12 @@ from rest_framework.generics import ListAPIView, RetrieveAPIView
from reqman.apps.account.models import User
from reqman.apps.reqtool.rest_api.serializers import UserSerializer
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
import json
from django.core.mail import send_mail
from django.conf import settings
class UserList(ListAPIView):
queryset = User.objects.all()
......@@ -10,4 +16,24 @@ class UserList(ListAPIView):
class UserDetail(RetrieveAPIView):
queryset = User.objects.all()
serializer_class = UserSerializer
\ No newline at end of file
serializer_class = UserSerializer
@csrf_exempt
def signup(request):
if request.method == 'POST':
data = json.loads(request.body)
mail = data['email']
username = data['username']
password = data['password1']
send_mail(
'New register from Requirement tool',
' Username :'+username+'\n Mail:'+mail+' \n Password:'+password,
settings.EMAIL_HOST_USER,
['nestorid@gapps.auth.gr'],
fail_silently=False,
)
return HttpResponse("OK")
else:
return HttpResponse("Error")
#form = UserCreationForm()
#return render(request, 'signup.html', {'form': form})
\ No newline at end of file
......@@ -30,7 +30,7 @@ def rel(*path):
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env.bool("REQMAN_DEBUG")
ALLOWED_HOSTS = env.list("REQMAN_ALLOWED_HOSTS", default=["127.0.0.1", "155.207.131.19"])
ALLOWED_HOSTS = env.list("REQMAN_ALLOWED_HOSTS")
SECRET_KEY = env.str("REQMAN_SECRET_KEY")
......@@ -157,8 +157,21 @@ JWT_AUTH = {
CORS_ORIGIN_ALLOW_ALL = False # If this is used then `CORS_ORIGIN_WHITELIST` will not have any effect
CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_WHITELIST = [
'http://155.207.131.19:8081',
env('UI_URL'),
] # If this is used, then not need to use `CORS_ORIGIN_ALLOW_ALL = True`
CORS_ORIGIN_REGEX_WHITELIST = [
'http://155.207.131.19:8081',
env('UI_URL'),
]
CSRF_TRUSTED_ORIGINS = [env('UI_URL')]
# Email config
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = env('EMAIL_HOST')
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = env('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = env('EMAIL_HOST_PASSWORD')
\ No newline at end of file
Markdown is supported
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