Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.30 KB | None | 0 0
  1. <!-- <head>
  2. <script type="text/javascript" src="https://cdn.emailjs.com/sdk/2.2.4/email.min.js"></script>
  3. <script type="text/javascript">
  4. (function(){
  5. emailjs.init("user_BZ86ay3RXqJTfSXYVlDfh");
  6. })();
  7. </script>
  8. </head> -->
  9. <mat-card>
  10. <div fxLayout="row wrap">
  11. <div fxFlex="100" fxFlex.gt-sm="50" class="p-2">
  12. <h2 class="text-muted text-center">Log In</h2>
  13. <form [formGroup]="loginForm" (ngSubmit)="onLoginFormSubmit(loginForm.value)">
  14. <mat-form-field class="w-100 mt-2">
  15. <input matInput placeholder="Email" formControlName="email" required>
  16. <mat-error *ngIf="loginForm.controls.email.errors?.required">Email is vereist</mat-error>
  17. <mat-error *ngIf="loginForm.controls.email.hasError('invalidEmail')">Ongeldig e-mail adres</mat-error>
  18. </mat-form-field>
  19. <mat-form-field class="w-100 mt-1">
  20. <input matInput placeholder="Wachtwoord" type="password" formControlName="password" required>
  21. <mat-error *ngIf="loginForm.controls.password.errors?.required">Wachtwoord is vereist</mat-error>
  22. <mat-error *ngIf="loginForm.controls.password.hasError('minlength')">Wachtwoord is niet lang genoeg, minimaal 6 karakters</mat-error>
  23. </mat-form-field>
  24. <div class="text-center mt-2">
  25. <button mat-fab color="primary" class="mat-elevation-z6" (click)="onLoginFormSubmit(loginForm.value)">
  26. <mat-icon>exit_to_app</mat-icon>
  27. </button>
  28. </div>
  29.  
  30. <div fxLayout="row" fxLayoutAlign="space-between center" class="mt-2">
  31. <div class="divider w-100"></div>
  32. <h3 class="text-muted auth">Of log in met een klik</h3>
  33. <div class="divider w-100"></div>
  34. </div>
  35.  
  36. <div class="text-center py-2">
  37. <svg class="social-icon" viewBox="0 0 24 24" matTooltip="Facebook">
  38. <path d="M5,3H19A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21H5A2,2 0 0,1 3,19V5A2,2 0 0,1 5,3M18,5H15.5A3.5,3.5 0 0,0 12,8.5V11H10V14H12V21H15V14H18V11H15V9A1,1 0 0,1 16,8H18V5Z" />
  39. </svg>
  40. <svg class="social-icon" viewBox="0 0 24 24" matTooltip="Twitter">
  41. <path d="M5,3H19A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21H5A2,2 0 0,1 3,19V5A2,2 0 0,1 5,3M17.71,9.33C18.19,8.93 18.75,8.45 19,7.92C18.59,8.13 18.1,8.26 17.56,8.33C18.06,7.97 18.47,7.5 18.68,6.86C18.16,7.14 17.63,7.38 16.97,7.5C15.42,5.63 11.71,7.15 12.37,9.95C9.76,9.79 8.17,8.61 6.85,7.16C6.1,8.38 6.75,10.23 7.64,10.74C7.18,10.71 6.83,10.57 6.5,10.41C6.54,11.95 7.39,12.69 8.58,13.09C8.22,13.16 7.82,13.18 7.44,13.12C7.81,14.19 8.58,14.86 9.9,15C9,15.76 7.34,16.29 6,16.08C7.15,16.81 8.46,17.39 10.28,17.31C14.69,17.11 17.64,13.95 17.71,9.33Z" />
  42. </svg>
  43. <svg class="social-icon" viewBox="0 0 24 24" matTooltip="Google">
  44. <path d="M5,3H19A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21H5A2,2 0 0,1 3,19V5A2,2 0 0,1 5,3M19.5,12H18V10.5H17V12H15.5V13H17V14.5H18V13H19.5V12M9.65,11.36V12.9H12.22C12.09,13.54 11.45,14.83 9.65,14.83C8.11,14.83 6.89,13.54 6.89,12C6.89,10.46 8.11,9.17 9.65,9.17C10.55,9.17 11.13,9.56 11.45,9.88L12.67,8.72C11.9,7.95 10.87,7.5 9.65,7.5C7.14,7.5 5.15,9.5 5.15,12C5.15,14.5 7.14,16.5 9.65,16.5C12.22,16.5 13.96,14.7 13.96,12.13C13.96,11.81 13.96,11.61 13.89,11.36H9.65Z" />
  45. </svg>
  46. </div>
  47.  
  48. </form>
  49. </div>
  50. <div fxFlex="100" fxFlex.gt-sm="50" class="p-2" ngClass.sm="mt-2" ngClass.xs="mt-2">
  51. <h2 class="text-muted text-center">Nog geen account? Registreer nu!</h2>
  52. <form [formGroup]="registerForm" (ngSubmit)="onRegisterFormSubmit(registerForm.value)">
  53. <mat-form-field class="w-100 mt-2">
  54. <input matInput placeholder="Volledige Naam" formControlName="name" required [(ngModel)]="Partij?.Partij.sGebruiker">
  55. <mat-error *ngIf="registerForm.controls.name.errors?.required">Voledige Naam is vereist</mat-error>
  56. <mat-error *ngIf="registerForm.controls.name.hasError('minlength')">Voledige naam is vereist</mat-error>
  57. </mat-form-field>
  58. <mat-form-field class="w-100 mt-2">
  59. <input matInput placeholder="Gebruikersnaam" formControlName="name" required [(ngModel)]="Partij?.Partij.sGebruikersnaam">
  60. <mat-error *ngIf="registerForm.controls.name.errors?.required">Gebruikersnaam is vereist</mat-error>
  61. <mat-error *ngIf="registerForm.controls.name.hasError('minlength')">Gebruikersnaam is vereist</mat-error>
  62. </mat-form-field>
  63. <mat-form-field class="w-100 mt-1">
  64. <input matInput placeholder="Email" formControlName="email" required [(ngModel)]="Partij?.Partij.sMail">
  65. <mat-error *ngIf="registerForm.controls.email.errors?.required">Email is vereist</mat-error>
  66. <mat-error *ngIf="registerForm.controls.email.hasError('invalidEmail')">Ongeldige e-mail adres</mat-error>
  67. </mat-form-field>
  68. <mat-form-field class="w-100 mt-1">
  69. <input matInput placeholder="Wachtwoord" formControlName="password" type="password" minlength="6" required [(ngModel)]="Partij?.Partij.sWachtwoord">
  70. <mat-error *ngIf="registerForm.controls.password.errors?.required">Wachtwoord is vereist</mat-error>
  71. <mat-error *ngIf="registerForm.controls.password.hasError('minlength')">Wachtwoord is niet lang genoeg, minimaal 6 karakters</mat-error>
  72. </mat-form-field>
  73. <mat-form-field class="w-100 mt-1">
  74. <input matInput placeholder="Bevestig Wachtwoord" formControlName="confirmPassword" type="password" required>
  75. <mat-error *ngIf="registerForm.controls.confirmPassword.errors?.required">Wachtwoord is vereist</mat-error>
  76. <mat-error *ngIf="registerForm.controls.confirmPassword.hasError('mismatchedPasswords')">Wachtwoorden komen niet overeen</mat-error>
  77. </mat-form-field>
  78. <div class="text-center mt-2">
  79. <button mat-fab color="primary" class="mat-elevation-z6" (click)="onRegisterFormSubmit(registerForm.value)" (click)="on_iPartij()" (click)="on_iEmail()">
  80. <mat-icon>person_add</mat-icon>
  81. </button>
  82. </div>
  83. </form>
  84. </div>
  85. </div>
  86. </mat-card>
  87.  
  88. ============================================================================================================
  89. import { Component, OnInit } from '@angular/core';
  90. import { Router } from '@angular/router';
  91. import { FormBuilder, FormGroup, Validators } from '@angular/forms';
  92. import { MatSnackBar } from '@angular/material';
  93. import { emailValidator, matchingPasswords } from '../../theme/utils/app-validators';
  94. import { DataService } from './../../../services/data.service';
  95.  
  96. @Component({
  97. selector: 'app-sign-in',
  98. templateUrl: './sign-in.component.html',
  99. styleUrls: ['./sign-in.component.scss']
  100. })
  101. export class SignInComponent implements OnInit {
  102. loginForm: FormGroup;
  103. registerForm: FormGroup;
  104.  
  105. constructor(public formBuilder: FormBuilder, public router:Router, public snackBar: MatSnackBar, public ds: DataService) { }
  106.  
  107. ngOnInit() {
  108. this.loginForm = this.formBuilder.group({
  109. 'email': ['', Validators.compose([Validators.required, emailValidator])],
  110. 'password': ['', Validators.compose([Validators.required, Validators.minLength(6)])]
  111. });
  112.  
  113. this.registerForm = this.formBuilder.group({
  114. 'name': ['', Validators.compose([Validators.required, Validators.minLength(3)])],
  115. 'email': ['', Validators.compose([Validators.required, emailValidator])],
  116. 'password': ['', Validators.required],
  117. 'confirmPassword': ['', Validators.required]
  118. },{validator: matchingPasswords('password', 'confirmPassword')});
  119.  
  120. this.sPartijViaID("5bfbd6ef7e04b021103c3d28")
  121. this.sEmailViaID("5c1231507e04b02308c16ff7")
  122. }
  123.  
  124. public onLoginFormSubmit(values:Object):void {
  125. if (this.loginForm.valid) {
  126. this.router.navigate(['/products']);
  127. }
  128. }
  129.  
  130. public onRegisterFormSubmit(values:Object):void {
  131. if (this.registerForm.valid) {
  132. this.snackBar.open('You registered successfully!', '×', { panelClass: 'success', verticalPosition: 'top', duration: 3000 });
  133. }
  134. }
  135. Partij;
  136. Email;
  137. sPartijViaID(_id){
  138.  
  139. let req = {
  140.  
  141. sToken: "",
  142.  
  143. _id: _id
  144.  
  145. }
  146.  
  147. this.ds.sPartijViaID(req).subscribe(res => {
  148.  
  149. this.Partij = res
  150.  
  151. console.log("Response van sPartijlViaID", res)
  152.  
  153. })
  154.  
  155. }
  156.  
  157. on_iPartij(){
  158.  
  159. let req = {
  160.  
  161. sToken: "",
  162.  
  163. Partij: this.Partij
  164.  
  165. }
  166.  
  167. console.log("Partij", this.Partij)
  168.  
  169. this.ds.iPartij(req).subscribe(res => {
  170.  
  171. console.log("Response van iPartij", res)
  172.  
  173. })}
  174.  
  175. sEmailViaID(_id){
  176.  
  177. let req = {
  178.  
  179. sToken: "",
  180.  
  181. _id: _id
  182.  
  183. }
  184.  
  185. this.ds.sEmailViaID(req).subscribe(res => {
  186.  
  187. this.Email = res
  188.  
  189. console.log("Response van sEmailViaID", res)
  190.  
  191. })
  192.  
  193. }
  194.  
  195. on_iEmail(){
  196.  
  197. let req = {
  198.  
  199. sToken: "",
  200.  
  201. Email: this.Email
  202.  
  203. }
  204.  
  205. console.log("Partij", this.Email)
  206.  
  207. this.ds.iEmail(req).subscribe(res => {
  208.  
  209. console.log("Response van iEmail", res)
  210.  
  211. })}
  212.  
  213. // var email = require("./path/to/emailjs/email");
  214. // var server = email.server.connect({
  215. // user: "username",
  216. // password:"password",
  217. // host: "smtp.your-email.com",
  218. // ssl: true
  219. // });
  220.  
  221. // // send the message and get a callback with an error or details of the message that was sent
  222. // server.send({
  223. // text: "i hope this works",
  224. // from: "you <username@your-email.com>",
  225. // to: "someone <someone@your-email.com>, another <another@your-email.com>",
  226. // cc: "else <else@your-email.com>",
  227. // subject: "testing emailjs"
  228. // }, function(err, message) { console.log(err || message); });
  229.  
  230. }
  231.  
  232.  
  233. ==================================================================================
  234. sEmailViaID(req) {
  235.  
  236. req.sToken = this.sToken
  237.  
  238. return this.httpclient.post(this.sUrl + 'sEmailViaID', req)
  239.  
  240. }
  241.  
  242.  
  243.  
  244. iEmail(req) {
  245.  
  246. req.sToken = this.sToken
  247.  
  248. return this.httpclient.post(this.sUrl + 'iEmail', req)
  249.  
  250. }
  251. ===============================================================================
  252. app.post('/api/iEmail', function (req, res) {
  253.  
  254. db.email.insert(req.body.Email, {}, function (e, results) {
  255.  
  256. res.json({sStatus:'Inactief'})
  257.  
  258. });
  259.  
  260. });
  261. app.post('/api/sEmailViaID', function (req, res) {
  262.  
  263. var id = ObjectId(req.body._id)
  264.  
  265. db.email.findOne({ '_id': id},
  266.  
  267. function (err, docs) {
  268.  
  269. if (err) {
  270.  
  271. res.json({sStatus:'Email niet gevonden'})
  272.  
  273. } else {
  274.  
  275. res.json(docs)
  276.  
  277. }
  278.  
  279. });
  280.  
  281. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement