PageSourceSearch

https://thsba.net/services/profile_service.js

js thsba.net collected 2026-10-02 00:03:27 UTC 13,887 bytes, 311 lines download raw bytes

1angular.module('main').factory('profileService', function($q, $http, $cookies) {
2    return {
3        authenticate : function(type, email, password) {
4            return $http({
5                url: `${domain}/v1/${type}/login`,
6                headers: {
7                    "apiKey": "dGhzYmEtYXBpLWtleQ==",
8                    "Authorization": `Basic ${btoa(`${email}:${password}`)}`
9                },
10                method: "GET",
11                timeout: 5000
12            }).then(function(response) {
13                if(response == null || response.status != 200 || response.data == null) {
14                    return $q.reject("Unable to authenticate at this time. Please try again later.")
15                }
16                /* store user_profile */
17                let token_data = response.data;
18                token_data.type = type;
19                $cookies.put('user_token', JSON.stringify(token_data));
20                return token_data;     
21            }, function error(response) {
22                // Handle error here
23                if(response.data != null && response.data.message != null) {
24                    return $q.reject(response.data.message);
25                }
26    
27                return $q.reject("Unable to authenticate at this time. Please try again later.")
28            });
29        },
30        signup : function(profile, type) {
31            return $http({
32                url: `${domain}/v2/${type}/new`,
33                headers: {
34                    "apiKey": "dGhzYmEtYXBpLWtleQ=="
35                },
36                data: profile,
37                method: "POST",
38                timeout: 5000
39            }).then(function(response) {
40                if(response == null || response.status != 200 || response.data == null) {
41                    return $q.reject("Unable to create account at this time. Please try again later.")
42                }
43                return response.data;     
44            }, function error(response) {
45                // Handle error here
46                if(response.data != null && response.data.message != null) {
47                    return $q.reject(response.data.message);
48                }
49    
50                return $q.reject("Unable to create account at this time. Please try again later.")
51            });      
52        },
53        forgotPassword : function(email) {
54
55        },
56        getProfileType : function() {
57            let user_token = JSON.parse($cookies.get('user_token') || "{}");
58            let type = user_token.type;
59            return type;
60        },
61        getProfile : function() {
62            let user_token = JSON.parse($cookies.get('user_token') || "{}");
63            let authorization = user_token.access_token;
64            let type = user_token.type;
65
66            if (type == null) { return $q.reject("Unable to retrieve your profile at this time. Please try again later."); }
67
68            return $http({
69                url: `${domain}/v1/${type}`,
70                headers: {
71                    "apiKey": "dGhzYmEtYXBpLWtleQ==",
72                    "Authorization": `Bearer ${authorization}`
73                },
74                method: "GET",
75                timeout: 5000
76            }).then(function(response) {
77                if(response == null || response.status != 200 || response.data == null) {
78                    return $q.reject("Unable to retrieve your profile at this time. Please try again later.")
79                }
80                return response.data;     
81            }, function error(response) {
82                // Handle error here
83                if(response.data != null && response.data.message != null) {
84                    return $q.reject(response.data.message);
85                }
86    
87                return $q.reject("Unable to retrieve your profile at this time. Please try again later.")
88            });
89        },
90        updateProfile : function(profile) {
91            let user_token = JSON.parse($cookies.get('user_token') || "{}");
92            let authorization = user_token.access_token;
93            let type = user_token.type;
94
95            if (type == null) { return $q.reject("Unable to retrieve your profile at this time. Please try again later."); }
96
97            return $http({
98                url: `${domain}/v1/${type}`,
99                headers: {
100                    "apiKey": "dGhzYmEtYXBpLWtleQ==",
101                    "Authorization": `Bearer ${authorization}`
102                },
103                data: profile,
104                method: "PUT",
105                timeout: 5000
106            }).then(function(response) {
107                if(response == null || response.status != 200 || response.data == null) {
108                    return $q.reject("Unable to update your profile at this time. Please try again later.")
109                }
110                return response.data;     
111            }, function error(response) {
112                // Handle error here
113                if(response.data != null && response.data.message != null) {
114                    return $q.reject(response.data.message);
115                }
116    
117                return $q.reject("Unable to update your profile at this time. Please try again later.")
118            });
119        },
120        uploadSafeSport: function(resultForm) {
121            let user_token = JSON.parse($cookies.get('user_token') || "{}");
122            let authorization = user_token.access_token;
123            let type = user_token.type;
124            return $http.put(`${domain}/v1/${type}/safe-sport`, resultForm, 
125            {
126                transformRequest: angular.identity,
127                headers: {'Content-Type': undefined,
128                'authorization': 'Bearer ' + authorization,
129                'apiKey': 'dGhzYmEtYXBpLWtleQ==' }
130            }).then(function(response) {
131                if(response == null || response.status != 200 || response.data == null) {
132                    return $q.reject('Unable to upload tournament results. Please try again.');
133                }
134                
135                return response.data;
136
137            }).catch(function error(response) {
138                if(response.data != null && response.data.message != null) {
139                    return $q.reject(response.data.message);
140                } else if (response.data != null){
141                    return $q.reject(response.data);
142                } {
143                    return $q.reject('Unable to upload tournament results. Please try again.');
144                }
145            });
146        },
147        lookupProfileById : function(type, id) {
148            let user_token = JSON.parse($cookies.get('user_token') || "{}");
149            let authorization = user_token.access_token;
150
151            if (type == null) { return $q.reject("Unable to lookup profile at this time. Please try again later."); }
152
153            return $http({
154                url: `${domain}/v1/${type}/${id}`,
155                headers: {
156                    "apiKey": "dGhzYmEtYXBpLWtleQ==",
157                    "Authorization": `Bearer ${authorization}`
158                },
159                method: "GET",
160                timeout: 5000
161            }).then(function(response) {
162                if(response == null || response.status != 200 || response.data == null) {
163                    return $q.reject("Unable to lookup profile at this time. Please try again later.")
164                }
165                return response.data;     
166            }, function error(response) {
167                // Handle error here
168                if(response.data != null && response.data.message != null) {
169                    return $q.reject(response.data.message);
170                }
171    
172                return $q.reject("Unable to lookup profile at this time. Please try again later.")
173            });
174        },
175        lookupProfileByName : function(type, firstName, lastName, tournamentId) {
176            let user_token = JSON.parse($cookies.get('user_token') || "{}");
177            let authorization = user_token.access_token;
178
179            if (type == null) { return $q.reject("Unable to lookup profile at this time. Please try again later."); }
180
181            return $http({
182                url: `${domain}/v1/${type}s?firstName=${firstName}&lastName=${lastName}${tournamentId != null ? `&tournamentId=${tournamentId}` : ''}`,
183                headers: {
184                    "apiKey": "dGhzYmEtYXBpLWtleQ==",
185                    "Authorization": `Bearer ${authorization}`
186                },
187                method: "GET",
188                timeout: 5000
189            }).then(function(response) {
190                if(response == null || response.status != 200 || response.data == null) {
191                    return $q.reject("Unable to lookup profile at this time. Please try again later.")
192                }
193                return response.data;     
194            }, function error(response) {
195                // Handle error here
196                if(response.data != null && response.data.message != null) {
197                    return $q.reject(response.data.message);
198                }
199    
200                return $q.reject("Unable to lookup profile at this time. Please try again later.")
201            });
202        },
203        lookupProfileByEmail : function(type, email) {
204            if (type == null) { return $q.reject("Unable to check for existing profiile at this time. Please try again later."); }
205
206            return $http({
207                url: `${domain}/v1/${type}/exists/email/${email}`,
208                headers: {
209                    "apiKey": "dGhzYmEtYXBpLWtleQ=="
210                },
211                method: "GET",
212                timeout: 5000
213            }).then(function(response) {
214                if(response == null || response.status != 200 || response.data == null) {
215                    return $q.reject("Unable to check for existing profile at this time. Please try again later.")
216                }
217                return response.data;     
218            }, function error(response) {
219                // Handle error here
220                if(response.data != null && response.data.message != null) {
221                    return $q.reject(response.data.message);
222                }
223    
224                return $q.reject("Unable to check for existing profile at this time. Please try again later.")
225            });
226        },
227        forgotPassword : function(type, email) {
228            return $http({
229                url: `${domain}/v1/${type}/forgot/password`,
230                headers: {
231                    "apiKey": "dGhzYmEtYXBpLWtleQ=="
232                },
233                data: {
234                    email: email
235                },
236                method: "POST",
237                timeout: 5000
238            }).then(function(response) {
239                if(response == null || response.status != 200 || response.data == null) {
240                    return $q.reject("Unable to reset password at this time. Please try again later.")
241                }
242                return response.data;     
243            }, function error(response) {
244                // Handle error here
245                if(response.data != null && response.data.message != null) {
246                    return $q.reject(response.data.message);
247                }
248    
249                return $q.reject("Unable to reset password at this time. Please try again later.")
250            });
251        },
252        resendEnrollmentEmail : function() {
253            let user_token = JSON.parse($cookies.get('user_token') || "{}");
254            let authorization = user_token.access_token;
255            let type = user_token.type;
256
257            if (type == null) { return $q.reject("Unable to resend enrollment email at this time. Please try again later."); }
258
259            return $http({
260                url: `${domain}/v1/${type}/resend-verify`,
261                headers: {
262                    "apiKey": "dGhzYmEtYXBpLWtleQ==",
263                    "Authorization": `Bearer ${authorization}`
264                },
265                method: "PUT",
266                timeout: 5000
267            }).then(function(response) {
268                if(response == null || response.status != 200 || response.data == null) {
269                    return $q.reject("Unable to resend enrollment email at this time Please try again later.")
270                }
271                return response.data;     
272            }, function error(response) {
273                // Handle error here
274                if(response.data != null && response.data.message != null) {
275                    return $q.reject(response.data.message);
276                }
277    
278                return $q.reject("Unable to resend enrollment email at this time. Please try again later.")
279            });
280        },
281
282        getAllResults : function(type) {
283            let user_token = JSON.parse($cookies.get('user_token') || "{}");
284            let authorization = user_token.access_token;
285
286            if (type == null) { return $q.reject("Unable to lookup profile at this time. Please try again later."); }
287
288            return $http({
289                url: `${domain}/v1/results/${type}`,
290                headers: {
291                    "apiKey": "dGhzYmEtYXBpLWtleQ==",
292                    "Authorization": `Bearer ${authorization}`
293                },
294                method: "GET",
295                timeout: 5000
296            }).then(function(response) {
297                if(response == null || response.status != 200 || response.data == null) {
298                    return $q.reject("Unable to retrieve results. Please try again later.")
299                }
300                return response.data;     
301            }, function error(response) {
302                // Handle error here
303                if(response.data != null && response.data.message != null) {
304                    return $q.reject(response.data.message);
305                }
306    
307                return $q.reject("Unable to retrieve results. Please try again later.")
308            });
309        },
310    }
311});

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.