Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

basicauth.js 966B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. 'use strict';
  2. const AuthPrompt = require('../types/auth');
  3. function defaultAuthenticate(value, state) {
  4. if (value.username === this.options.username && value.password === this.options.password) {
  5. return true;
  6. }
  7. return false;
  8. }
  9. const factory = (authenticate = defaultAuthenticate) => {
  10. const choices = [
  11. { name: 'username', message: 'username' },
  12. {
  13. name: 'password',
  14. message: 'password',
  15. format(input) {
  16. if (this.options.showPassword) {
  17. return input;
  18. }
  19. let color = this.state.submitted ? this.styles.primary : this.styles.muted;
  20. return color(this.symbols.asterisk.repeat(input.length));
  21. }
  22. }
  23. ];
  24. class BasicAuthPrompt extends AuthPrompt.create(authenticate) {
  25. constructor(options) {
  26. super({ ...options, choices });
  27. }
  28. static create(authenticate) {
  29. return factory(authenticate);
  30. }
  31. }
  32. return BasicAuthPrompt;
  33. };
  34. module.exports = factory();