PageSourceSearch

https://prattcenter.net/assets/gray_matter/authentication/authenti…f95be360790c142de5ebfbd644a656adc2b2fbd1.js

js prattcenter.net collected 2026-09-24 18:03:31 UTC 1,744 bytes, 62 lines download raw bytes

1// Copyright (c) 2021-2025 GrayBits LLC
2
3import Errors from 'gray_matter/forms/errors'
4import axios from 'axios'
5
6export default class AuthenticationForm{
7  constructor(form, options){
8    this.form = form;
9    this.form.addEventListener('submit', e => this.submitForm(e));
10    if (options){
11      this.preSubmit = options.pre_submit;
12      this.postSubmit = options.post_submit;
13    }
14    if (this.setup) this.setup();
15    this.errors = new Errors(this.form);
16  }
17
18  async submitForm(e){
19    e.preventDefault();
20    e.stopPropagation();
21    this.initRequest(e);
22    try {
23      if (this.preSubmit) this.preSubmit();
24      let method = this.form.querySelector('input[name="_method"]');
25      method = method ? method.value : this.form.method;
26      const response = await axios.request({
27        url: this.form.action, 
28        data: new FormData(this.form), 
29        method: method
30      });
31      this.form.querySelector('button').disabled = false;
32      if (response.data.redirect_to){
33        Turbo.visit(response.data.redirect_to);
34        return;
35      }
36      if (this.postSubmit) this.postSubmit(response); 
37    } catch(error) {
38      if (this.form.error) this.form.error(error);
39      this.errors.clear();
40      this.errors.show(error.response.data);
41      this.form.querySelector('button').disabled = false;
42    }
43  }
44
45  initRequest(e){
46    e.preventDefault();
47    e.stopPropagation();
48    this.errors.clear();
49    this.form.querySelector('button').disabled = true;
50  }
51
52  static initInstance(e, options){
53    if (!e.initialized){
54      new this(e, options);
55      e.initialized = true;
56    }
57  }
58
59  static init(options){
60    document.querySelectorAll('form.' + this.formClass()).forEach((e) => this.initInstance(e, options));
61  }
62};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.