├── CONTRIBUTING.md
├── Demos
├── Lazarus
│ └── Simple Demo
│ │ ├── .env-example
│ │ ├── SimpleDemo.ico
│ │ ├── SimpleDemo.res
│ │ ├── lib
│ │ └── x86_64-win64
│ │ │ ├── SimpleDemo.obj
│ │ │ ├── SimpleDemo.res
│ │ │ ├── eFirebase.ppu
│ │ │ ├── unitmain.ppu
│ │ │ ├── DotEnv4Delphi.ppu
│ │ │ ├── eFirebase.Auth.ppu
│ │ │ ├── eFirebase.Types.ppu
│ │ │ ├── eFirebase.rest.ppu
│ │ │ ├── eFirebase.Storage.ppu
│ │ │ ├── eFirebase.Interfaces.ppu
│ │ │ ├── eFirebase.RealTimeDB.ppu
│ │ │ ├── eFirebase.Responses.Auth.ppu
│ │ │ ├── eFirebase.request.lazarus.ppu
│ │ │ ├── eFirebase.Responses.Storage.ppu
│ │ │ ├── eFirebase.request.contract.ppu
│ │ │ ├── eFirebase.response.contract.ppu
│ │ │ ├── eFirebase.response.lazarus.ppu
│ │ │ ├── eFirebase.Responses.RealTimeDB.ppu
│ │ │ └── SimpleDemo.compiled
│ │ ├── boss.json
│ │ ├── SimpleDemo.lpr
│ │ ├── boss-lock.json
│ │ ├── SimpleDemo.lpi
│ │ ├── backup
│ │ ├── SimpleDemo.lpi
│ │ ├── SimpleDemo.lps
│ │ └── unitmain.pas
│ │ ├── SimpleDemo.lps
│ │ ├── unitmain.pas
│ │ └── unitmain.lfm
└── Delphi
│ └── Simple Demo - FMX
│ ├── .env-example
│ ├── UnitMain.pas
│ ├── SimpleDemoFMX.res
│ ├── SimpleDemoFMX.dpr
│ ├── boss.json
│ ├── boss-lock.json
│ └── UnitMain.vlb
├── source
├── eFirebase.pas
├── FirebaseLib
│ ├── eFirebase.Storage.pas
│ ├── eFirebase.RealTimeDB.pas
│ ├── Response Classes
│ │ ├── eFirebase.Responses.Auth.pas
│ │ ├── eFirebase.Responses.RealTimeDB.pas
│ │ └── eFirebase.Responses.Storage.pas
│ └── eFirebase.Auth.pas
├── RestLib
│ ├── eFirebase.response.contract.pas
│ ├── eFirebase.rest.pas
│ ├── eFirebase.request.contract.pas
│ ├── eFirebase.response.pas
│ ├── eFirebase.response.lazarus.pas
│ ├── eFirebase.request.pas
│ └── eFirebase.request.lazarus.pas
├── eFirebase.Types.pas
└── eFirebase.Interfaces.pas
├── Design
├── Design_logo.pptx
├── Logo_eFirebase.xcf
└── eFirebase_art.pptx.png
├── Imagens
├── Delphi_logo.png
└── Logo_eFirebase.png
├── boss-lock.json
├── .github
└── ISSUE_TEMPLATE
│ ├── custom.md
│ ├── feature_request.md
│ └── bug_report.md
├── boss.json
├── SECURITY.md
├── LICENSE
├── .gitignore
├── Comandos.txt
├── README.md
└── CODE_OF_CONDUCT.md
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Write te Contributing here
2 |
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/.env-example:
--------------------------------------------------------------------------------
1 | APIKey=
2 | ProjectId=
--------------------------------------------------------------------------------
/Demos/Delphi/Simple Demo - FMX/.env-example:
--------------------------------------------------------------------------------
1 | APIKey=
2 | ProjectId=
--------------------------------------------------------------------------------
/source/eFirebase.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/source/eFirebase.pas
--------------------------------------------------------------------------------
/Design/Design_logo.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Design/Design_logo.pptx
--------------------------------------------------------------------------------
/Imagens/Delphi_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Imagens/Delphi_logo.png
--------------------------------------------------------------------------------
/Design/Logo_eFirebase.xcf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Design/Logo_eFirebase.xcf
--------------------------------------------------------------------------------
/Imagens/Logo_eFirebase.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Imagens/Logo_eFirebase.png
--------------------------------------------------------------------------------
/Design/eFirebase_art.pptx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Design/eFirebase_art.pptx.png
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/SimpleDemo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Demos/Lazarus/Simple Demo/SimpleDemo.ico
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/SimpleDemo.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Demos/Lazarus/Simple Demo/SimpleDemo.res
--------------------------------------------------------------------------------
/boss-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "hash": "d41d8cd98f00b204e9800998ecf8427e",
3 | "updated": "2023-06-01T21:17:39.9888602-03:00",
4 | "installedModules": {}
5 | }
--------------------------------------------------------------------------------
/source/FirebaseLib/eFirebase.Storage.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/source/FirebaseLib/eFirebase.Storage.pas
--------------------------------------------------------------------------------
/Demos/Delphi/Simple Demo - FMX/UnitMain.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Demos/Delphi/Simple Demo - FMX/UnitMain.pas
--------------------------------------------------------------------------------
/source/FirebaseLib/eFirebase.RealTimeDB.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/source/FirebaseLib/eFirebase.RealTimeDB.pas
--------------------------------------------------------------------------------
/Demos/Delphi/Simple Demo - FMX/SimpleDemoFMX.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Demos/Delphi/Simple Demo - FMX/SimpleDemoFMX.res
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/lib/x86_64-win64/SimpleDemo.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Demos/Lazarus/Simple Demo/lib/x86_64-win64/SimpleDemo.obj
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/lib/x86_64-win64/SimpleDemo.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Demos/Lazarus/Simple Demo/lib/x86_64-win64/SimpleDemo.res
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.ppu:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.ppu
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/lib/x86_64-win64/unitmain.ppu:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Demos/Lazarus/Simple Demo/lib/x86_64-win64/unitmain.ppu
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/lib/x86_64-win64/DotEnv4Delphi.ppu:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Demos/Lazarus/Simple Demo/lib/x86_64-win64/DotEnv4Delphi.ppu
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.Auth.ppu:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.Auth.ppu
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.Types.ppu:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.Types.ppu
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.rest.ppu:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.rest.ppu
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.Storage.ppu:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.Storage.ppu
--------------------------------------------------------------------------------
/source/FirebaseLib/Response Classes/eFirebase.Responses.Auth.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/source/FirebaseLib/Response Classes/eFirebase.Responses.Auth.pas
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.Interfaces.ppu:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.Interfaces.ppu
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.RealTimeDB.ppu:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.RealTimeDB.ppu
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/custom.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Custom issue template
3 | about: Describe this issue template's purpose here.
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.Responses.Auth.ppu:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.Responses.Auth.ppu
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.request.lazarus.ppu:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.request.lazarus.ppu
--------------------------------------------------------------------------------
/source/FirebaseLib/Response Classes/eFirebase.Responses.RealTimeDB.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/source/FirebaseLib/Response Classes/eFirebase.Responses.RealTimeDB.pas
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.Responses.Storage.ppu:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.Responses.Storage.ppu
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.request.contract.ppu:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.request.contract.ppu
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.response.contract.ppu:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.response.contract.ppu
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.response.lazarus.ppu:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.response.lazarus.ppu
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.Responses.RealTimeDB.ppu:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rafael-figueiredo-alves/eFirebase/HEAD/Demos/Lazarus/Simple Demo/lib/x86_64-win64/eFirebase.Responses.RealTimeDB.ppu
--------------------------------------------------------------------------------
/boss.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "eFirebase",
3 | "description": "Biclioteca para controlar o Firebase em aplicações Delphi e Lazarus",
4 | "version": "1.0.0",
5 | "homepage": "",
6 | "mainsrc": "./source",
7 | "projects": [],
8 | "dependencies": {}
9 | }
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/boss.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Simple Demo",
3 | "description": "",
4 | "version": "1.0.0",
5 | "homepage": "",
6 | "mainsrc": "./src",
7 | "projects": [],
8 | "dependencies": {
9 | "https://github.com/rafael-figueiredo-alves/dotenv4delphi": "^v1.4.0",
10 | "https://github.com/rafael-figueiredo-alves/efirebase": "^v1.1.1"
11 | }
12 | }
--------------------------------------------------------------------------------
/Demos/Delphi/Simple Demo - FMX/SimpleDemoFMX.dpr:
--------------------------------------------------------------------------------
1 | program SimpleDemoFMX;
2 |
3 | uses
4 | System.StartUpCopy,
5 | FMX.Forms,
6 | UnitMain in 'UnitMain.pas' {FormMain};
7 |
8 | {$R *.res}
9 |
10 | begin
11 | ReportMemoryLeaksOnShutdown := true;
12 | Application.Initialize;
13 | Application.CreateForm(TFormMain, FormMain);
14 | Application.Run;
15 | end.
16 |
--------------------------------------------------------------------------------
/Demos/Delphi/Simple Demo - FMX/boss.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Simple Demo - FMX",
3 | "description": "Demo Firemonkey do eFirebase",
4 | "version": "1.0.0",
5 | "homepage": "",
6 | "mainsrc": "./",
7 | "projects": [],
8 | "dependencies": {
9 | "https://github.com/rafael-figueiredo-alves/dotenv4delphi": "^v1.0.0",
10 | "https://github.com/rafael-figueiredo-alves/efirebase": "^v1.1.1"
11 | }
12 | }
--------------------------------------------------------------------------------
/source/RestLib/eFirebase.response.contract.pas:
--------------------------------------------------------------------------------
1 | unit eFirebase.response.contract;
2 |
3 | interface
4 |
5 | uses
6 | {$IFDEF FPC}
7 | Classes;
8 | {$ELSE}
9 | System.Classes;
10 | {$ENDIF}
11 |
12 | type
13 | iResponse = interface
14 | ['{AB4680D4-C4DC-4330-943D-2290C2657B9D}']
15 | function Content: string;
16 | function StatusCode: integer;
17 | function Headers: TStrings;
18 | function StatusMsg: string;
19 | function ErrorMessage: string;
20 | end;
21 |
22 | implementation
23 |
24 | end.
25 |
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/SimpleDemo.lpr:
--------------------------------------------------------------------------------
1 | program SimpleDemo;
2 |
3 | {$mode objfpc}{$H+}
4 |
5 | uses
6 | {$IFDEF UNIX}
7 | cthreads,
8 | {$ENDIF}
9 | {$IFDEF HASAMIGA}
10 | athreads,
11 | {$ENDIF}
12 | Interfaces, // this includes the LCL widgetset
13 | Forms, indylaz, unitMain
14 | { you can add units after this };
15 |
16 | {$R *.res}
17 |
18 | begin
19 | RequireDerivedFormResource:=True;
20 | Application.Scaled:=True;
21 | Application.Initialize;
22 | Application.CreateForm(TFormMain, FormMain);
23 | Application.Run;
24 | end.
25 |
26 |
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/boss-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "hash": "d41d8cd98f00b204e9800998ecf8427e",
3 | "updated": "2023-07-01T21:37:02.3126838-03:00",
4 | "installedModules": {
5 | "https://github.com/rafael-figueiredo-alves/dotenv4delphi": {
6 | "name": "dotenv4delphi",
7 | "version": "v1.4.0",
8 | "hash": "80c43793b38ed1ad4a659cfb068a6a15",
9 | "artifacts": {},
10 | "failed": false,
11 | "changed": false
12 | },
13 | "https://github.com/rafael-figueiredo-alves/efirebase": {
14 | "name": "efirebase",
15 | "version": "v1.1.0",
16 | "hash": "e38051cf93f228c89d0929ffd213a55c",
17 | "artifacts": {},
18 | "failed": false,
19 | "changed": false
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/Demos/Delphi/Simple Demo - FMX/boss-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "hash": "d41d8cd98f00b204e9800998ecf8427e",
3 | "updated": "2023-06-01T21:20:18.8691047-03:00",
4 | "installedModules": {
5 | "https://github.com/rafael-figueiredo-alves/dotenv4delphi": {
6 | "name": "dotenv4delphi",
7 | "version": "v1.4.0",
8 | "hash": "440722aa4c1d8757417bb69d5ccfe266",
9 | "artifacts": {},
10 | "failed": false,
11 | "changed": false
12 | },
13 | "https://github.com/rafael-figueiredo-alves/efirebase": {
14 | "name": "efirebase",
15 | "version": "v1.1.0",
16 | "hash": "a4a42cb53764f6c0c74a7c0c76a18b80",
17 | "artifacts": {},
18 | "failed": false,
19 | "changed": false
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | ## Supported Versions
4 |
5 | Use this section to tell people about which versions of your project are
6 | currently being supported with security updates.
7 |
8 | | Version | Supported |
9 | | ------- | ------------------ |
10 | | 5.1.x | :white_check_mark: |
11 | | 5.0.x | :x: |
12 | | 4.0.x | :white_check_mark: |
13 | | < 4.0 | :x: |
14 |
15 | ## Reporting a Vulnerability
16 |
17 | Use this section to tell people how to report a vulnerability.
18 |
19 | Tell them where to go, how often they can expect to get an update on a
20 | reported vulnerability, what to expect if the vulnerability is accepted or
21 | declined, etc.
22 |
--------------------------------------------------------------------------------
/source/RestLib/eFirebase.rest.pas:
--------------------------------------------------------------------------------
1 | unit eFirebase.rest;
2 |
3 | interface
4 |
5 | uses
6 | eFirebase.request.contract,
7 | eFirebase.response.contract;
8 |
9 | Type
10 | iRequest = eFirebase.request.contract.iRequest;
11 | iResponse = eFirebase.response.contract.iResponse;
12 |
13 | TRest = Class
14 | Public
15 | Class function New: iRequest;
16 | End;
17 |
18 | implementation
19 |
20 | uses
21 | {$IFDEF FPC}
22 | eFirebase.request.lazarus;
23 | {$Else}
24 | eFirebase.request;
25 | {$Endif}
26 |
27 | { TRest }
28 |
29 | class function TRest.New: iRequest;
30 | begin
31 | {$IFDEF FPC}
32 | Result := TRequestLazarus.Create
33 | {$Else}
34 | Result := TRequest.create;
35 | {$Endif}
36 | end;
37 |
38 | end.
39 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/source/eFirebase.Types.pas:
--------------------------------------------------------------------------------
1 | unit eFirebase.Types;
2 |
3 | interface
4 |
5 | type
6 | enumAuthErrors = (NONE,
7 | EMAIL_EXISTS,
8 | OPERATION_NOT_ALLOWED,
9 | TOO_MANY_ATTEMPTS_TRY_LATER,
10 | INVALID_EMAIL,
11 | WEAK_PASSWORD,
12 | EMAIL_NOT_FOUND,
13 | USER_DISABLED,
14 | TOKEN_EXPIRED,
15 | USER_NOT_FOUND,
16 | INVALID_REFRESH_TOKEN,
17 | INVALID_GRANT_TYPE,
18 | MISSING_REFRESH_TOKEN,
19 | EXPIRED_OOB_CODE,
20 | INVALID_OOB_CODE,
21 | INVALID_ID_TOKEN,
22 | CREDENTIAL_TOO_OLD_LOGIN_AGAIN,
23 | INVALID_PASSWORD,
24 | UNKNOWN);
25 |
26 | eContentType = (ctImagePNG, ctImageGIF, ctImageJPEG, ctImageJPG, ctTEXT);
27 |
28 | eFirebaseOrderByKind = (obkKey, obkValue, obkPriority);
29 |
30 | implementation
31 |
32 | end.
33 |
--------------------------------------------------------------------------------
/source/RestLib/eFirebase.request.contract.pas:
--------------------------------------------------------------------------------
1 | unit eFirebase.request.contract;
2 |
3 | interface
4 |
5 | uses
6 | eFirebase.response.contract,
7 | {$IFDEF FPC}
8 | Classes;
9 | {$ELSE}
10 | System.Classes;
11 | {$ENDIF}
12 |
13 | type
14 | iRequest = interface
15 | ['{E6F4955A-E71A-4734-9D45-809D9F89FE86}']
16 | function BaseUrl(Const BaseUrl: string): iRequest;
17 | function Resource(Const Resource : string): iRequest;
18 | function Body(const fbody: string): iRequest; overload;
19 | function Body(const fbody: TStream; const AOwns: Boolean): iRequest; overload;
20 | function SendFile(const FileName, ContentType: string):iRequest;
21 | function Token(Const pToken: string): iRequest;
22 | function AddParameter(const Key, Value: string):iRequest;
23 | function AddHeaders(const key, value: string):iRequest;
24 | function Get : iResponse;
25 | function Post : iResponse;
26 | function Patch : iResponse;
27 | function Delete : iResponse;
28 | function Put : iResponse;
29 | end;
30 |
31 | implementation
32 |
33 | end.
34 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Rafael de Figueiredo Alves
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/source/RestLib/eFirebase.response.pas:
--------------------------------------------------------------------------------
1 | unit eFirebase.response;
2 |
3 | interface
4 |
5 | uses
6 | eFirebase.response.contract,
7 | rest.Client,
8 | System.Classes;
9 |
10 | Type
11 | TResponse = Class(TInterfacedObject, iResponse)
12 | Private
13 | FRestResponse : tRESTResponse;
14 | Public
15 | Constructor Create(ARestResponse: TRESTResponse);
16 | Destructor Destroy; Override;
17 | Class function New(ARestResponse: TRESTResponse): iResponse;
18 | function Content: string;
19 | function StatusCode: integer;
20 | function Headers: TStrings;
21 | function StatusMsg: string;
22 | function ErrorMessage: string;
23 | End;
24 |
25 | implementation
26 |
27 | { TResponse }
28 |
29 | function TResponse.Content: string;
30 | begin
31 | Result := FRestResponse.Content;
32 | end;
33 |
34 | constructor TResponse.Create(ARestResponse: TRESTResponse);
35 | begin
36 | FRestResponse := ARestResponse;
37 | end;
38 |
39 | destructor TResponse.Destroy;
40 | begin
41 |
42 | inherited;
43 | end;
44 |
45 | function TResponse.ErrorMessage: string;
46 | begin
47 | Result := FRestResponse.ErrorMessage;
48 | end;
49 |
50 | function TResponse.Headers: TStrings;
51 | begin
52 | Result := FRestResponse.Headers;
53 | end;
54 |
55 | class function TResponse.New(ARestResponse: TRESTResponse): iResponse;
56 | begin
57 | Result := Self.Create(ARestResponse);
58 | end;
59 |
60 | function TResponse.StatusCode: integer;
61 | begin
62 | Result := FRestResponse.StatusCode;
63 | end;
64 |
65 | function TResponse.StatusMsg: string;
66 | begin
67 | Result := FRestResponse.StatusText;
68 | end;
69 |
70 | end.
71 |
--------------------------------------------------------------------------------
/source/RestLib/eFirebase.response.lazarus.pas:
--------------------------------------------------------------------------------
1 | unit eFirebase.response.lazarus;
2 |
3 | interface
4 |
5 | uses
6 | eFirebase.response.contract,
7 | IdHTTP,
8 | Classes;
9 |
10 | Type
11 | TResponseLazarus = Class(TInterfacedObject, iResponse)
12 | Private
13 | FidHTTP: TIdHTTP;
14 | Public
15 | Constructor Create(Const response: TIdHTTP);
16 | Destructor Destroy; Override;
17 | Class function New(const response: TIdHTTP): iResponse;
18 | function Content: string;
19 | function StatusCode: integer;
20 | function Headers: TStrings;
21 | function StatusMsg: string;
22 | function ErrorMessage: string;
23 | End;
24 |
25 | implementation
26 |
27 | { TResponseLazarus }
28 |
29 | function TResponseLazarus.Content: string;
30 | begin
31 | Result := tStringStream(FidHTTP.Response.ContentStream).DataString;
32 | end;
33 |
34 | Constructor TResponseLazarus.Create(Const response: TIdHTTP);
35 | begin
36 | FidHTTP := response;
37 | end;
38 |
39 | destructor TResponseLazarus.Destroy;
40 | begin
41 |
42 | inherited;
43 | end;
44 |
45 | function TResponseLazarus.ErrorMessage: string;
46 | begin
47 | Result := FidHTTP.Response.ResponseText;
48 | end;
49 |
50 | function TResponseLazarus.Headers: TStrings;
51 | begin
52 | Result := FidHTTP.Response.RawHeaders;
53 | end;
54 |
55 | class function TResponseLazarus.New(const response: TIdHTTP): iResponse;
56 | begin
57 | Result := Self.Create(response);
58 | end;
59 |
60 | function TResponseLazarus.StatusCode: integer;
61 | begin
62 | Result := FidHTTP.Response.ResponseCode;
63 | end;
64 |
65 | function TResponseLazarus.StatusMsg: string;
66 | begin
67 | Result := FidHTTP.Response.ResponseText;
68 | end;
69 |
70 | end.
71 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Uncomment these types if you want even more clean repository. But be careful.
2 | # It can make harm to an existing project source. Read explanations below.
3 | #
4 | # Resource files are binaries containing manifest, project icon and version info.
5 | # They can not be viewed as text or compared by diff-tools. Consider replacing them with .rc files.
6 | #*.res
7 | #
8 | # Type library file (binary). In old Delphi versions it should be stored.
9 | # Since Delphi 2009 it is produced from .ridl file and can safely be ignored.
10 | #*.tlb
11 | #
12 | # Diagram Portfolio file. Used by the diagram editor up to Delphi 7.
13 | # Uncomment this if you are not using diagrams or use newer Delphi version.
14 | #*.ddp
15 | #
16 | # Visual LiveBindings file. Added in Delphi XE2.
17 | # Uncomment this if you are not using LiveBindings Designer.
18 | #*.vlb
19 | #
20 | # Deployment Manager configuration file for your project. Added in Delphi XE2.
21 | # Uncomment this if it is not mobile development and you do not use remote debug feature.
22 | #*.deployproj
23 | #
24 | # C++ object files produced when C/C++ Output file generation is configured.
25 | # Uncomment this if you are not using external objects (zlib library for example).
26 | #*.obj
27 | #
28 |
29 | # Delphi compiler-generated binaries (safe to delete)
30 | *.exe
31 | *.dll
32 | *.bpl
33 | *.bpi
34 | *.dcp
35 | *.so
36 | *.apk
37 | *.drc
38 | *.map
39 | *.dres
40 | *.rsm
41 | *.tds
42 | *.dcu
43 | *.lib
44 | *.a
45 | *.o
46 | *.ocx
47 |
48 | # Delphi autogenerated files (duplicated info)
49 | *.cfg
50 | *.hpp
51 | *Resource.rc
52 |
53 | # Delphi local files (user-specific info)
54 | *.local
55 | *.identcache
56 | *.projdata
57 | *.tvsconfig
58 | *.dsk
59 |
60 | # Delphi history and backups
61 | __history/
62 | __recovery/
63 | *.~*
64 |
65 | # Castalia statistics file (since XE7 Castalia is distributed with Delphi)
66 | *.stat
67 |
68 | # Boss dependency manager vendor folder https://github.com/HashLoad/boss
69 | modules/
70 |
71 | # DotEnv environment variables during Development
72 | .env
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/lib/x86_64-win64/SimpleDemo.compiled:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Comandos.txt:
--------------------------------------------------------------------------------
1 | //auth := TeFirebase.New.Auth('AIzaSyCeUiXhD5rL0QgHoV1C8WkCg17n9n5teew').ChangeProfile('eyJhbGciOiJSUzI1NiIsImtpZCI6ImY4NzZiNzIxNDAwYmZhZmEyOWQ0MTFmZTYwODE2YmRhZWMyM2Iz' + 'ODIiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL3NlY3VyZXRva2VuLmdvb2dsZS5jb20vZXRhc2' + 'tzLWQ2OTg4IiwiYXVkIjoiZXRhc2tzLWQ2OTg4IiwiYXV0aF90aW1lIjoxNjc3NDU1NTEzLCJ1c2VyX2lkIjoiWDZ4bDJ' + 'iYzUwclRCVGpFZXZ4eVNoMVNRYU1iMiIsInN1YiI6Ilg2eGwyYmM1MHJUQlRqRWV2eHlTaDFTUWFNYjIiLCJ' + 'pYXQiOjE2Nzc0NTU1MTMsImV4cCI6MTY3NzQ1OTExMywiZW1haWwiOiJmYW1pbGlhLmFsdmVzMjAxM0BvdX' + 'Rsb29rLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwiZmlyZWJhc2UiOnsiaWRlbnRpdGllcyI6eyJlbWFpbCI6WyJmYW1p' + 'bGlhLmFsdmVzMjAxM0BvdXRsb29rLmNvbSJdfSwic2lnbl9pbl9wcm92aWRlciI6InBhc3N3b3JkIn19.V-ERTuN' + 'WPquSwO-LqRSeF_sUsboLOaKdFm7esq1A_8eSmXHBZIp1YlDWHJuxcylcbgSwn2vrQP5xJEQ_AqPIZ' + 'ZGLOLU0khIoW2VM90VZRdYWNbpbnaTr2Du3RswyvXFpOhguEsgehD45Q0NEmwvSauo0YKZgbr-RGdYiF1TeGrAczAQwAXrdG' + 'ga-RCYjTCbW9uJMIKPOU5rhtkrghnhIIKGhxBupXhMyMos3TFXX1Y0EuL4OncI8xRRTLIY91CG-BD5VW9x6GOJf258BCQXSUgV6BJ0HcvOhTK2mi1EPT8YBiRvN-QPk-AOTITfSBnj7zli9JkbA-1UkQNb17-S37Q', 'Developers Account', '');
2 | //auth := TeFirebase.New.Auth('AIzaSyCeUiXhD5rL0QgHoV1C8WkCg17n9n5teew').GetProfile('eyJhbGciOiJSUzI1NiIsImtpZCI6ImY4NzZiNzIxNDAwYmZhZmEyOWQ0MTFmZTYwODE2YmR' + 'hZWMyM2IzODIiLCJ0eXAiOiJKV1QifQ.eyJuYW1lIjoiRGV2ZWxvcGVycyBBY2NvdW' + '50IiwicGljdHVyZSI6IiIsImlzcyI6Imh0dHBzOi8vc2VjdXJldG9rZW4uZ29vZ2xlLmNvbS9ldGFza3MtZDY5ODgiLCJhdWQiOiJldGFza3MtZDY5ODgiL' + 'CJhdXRoX3RpbWUiOjE2Nzc5NzMxOTcsInVzZXJfaWQiOiJYNnhsMmJjNTByVEJUakVldnh5U2gxU1FhTWIyIiwic3ViIjoiWDZ4bDJiYz' + 'UwclRCVGpFZXZ4eVNoMVNRYU1iMiIsImlhdCI6MTY3Nzk3MzE5NywiZXhwIjoxNjc3OTc2Nzk3LCJlbWFpbCI6ImZhbWlsaWEuYWx2ZXMyMDEzQG91dGxvb2suY29tIiwiZ' + 'W1haWxfdmVyaWZpZWQiOmZhbHNlLCJmaXJlYmFzZSI6eyJpZGVudGl0aWVzIjp7ImVtYWlsIjpbImZhbWlsaWEuYWx2ZXMyMDEzQG91dGxvb2suY29tIl19LCJzaWduX2luX3Byb' + '3ZpZGVyIjoicGFzc3dvcmQifX0.pZFLjPm6zA7BaUiUVE05ghDNJVaC3WZXlFkrYcEFQAUCr6p18wAaKw8r7_M2XRD-IoYBGNZlPaBj1L8b4eJjTywPHyy6pWkSqvx32t27Qzm4I5AcxczQAmQ' + 'RB3jU_hY8WLPHrhc1svHSx_Hm5difRKEILZlH3cNaoFpfZweC_1V2GCn2g99HbygBWjBSzs4zhby-x5oqYjBkFy9sGusySqX841vt4Y_QDp9r_IDvvgCa77DCHxfo4PEVB_hamDFK-NfiMfQgFE0t3vefZKUHO_Fbk6v1ULjMe6snUwJdiv3XAmCF-8tNkHDPXgEzQ9ACzCvm-lal1VlSr_wjgKul_w');
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/SimpleDemo.lpi:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | -
29 |
30 |
31 | -
32 |
33 |
34 | -
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | -
78 |
79 |
80 | -
81 |
82 |
83 | -
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/backup/SimpleDemo.lpi:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | -
29 |
30 |
31 | -
32 |
33 |
34 | -
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | -
78 |
79 |
80 | -
81 |
82 |
83 | -
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | #
13 |
14 | ## Sobre
15 |
16 | eFirebase é uma biblioteca simples construída em Delphi para servir como um SDK para o consumo do [Firebase](https://console.firebase.google.com/) tanto pelo Delphi (a partir da versão XE2 até 11.3) como pelo Lazarus (testei apenas no 2.2.6, mas desde que tenha a biblioteca Indy, creio que deva rodar em outras inferiores, mas superiores a 2.0). Seu maior objetivo é ser simples, prático e oferecer o que outras bibliotecas já oferecem e um pouco a mais de forma muito simplificada.
17 |
18 | ## Recursos
19 |
20 | - Funções relacionadas ao controle de contas de usuário usando o Firebase Auth:
21 | - Poderá logar;
22 | - Poderá criar conta;
23 | - Poderá enviar e-mail de recuperação de senha;
24 | - Poderá acessar informações da conta;
25 | - Poderá apagar a conta;
26 | - Poderá verificar código de verificação de e-mail;
27 | - Poderá confirmar resetamento de senha com código enviado;
28 | - Poderá confirmar código de verificação de e-mail;
29 | - Poderá trocar senha;
30 | - Poderá alterar informações de conta.
31 |
32 | - Funções relacionadas ao controle de arquivos usando o Firebase Storage:
33 | - Poderá enviar arquivos;
34 | - Poderá obter links para acessar documentos/arquivos enviados.
35 |
36 | - Funções relacionadas ao banco de dados NoSQL do Firebase (Realtime Database):
37 | - Criação de coleções;
38 | - Leitura de dados de uma coleção;
39 | - Filtragem dos dados;
40 | - CRUD completo.
41 |
42 | - A biblioteca oferece suporte as funcionalidades usando chamadas a API Rest do Firebase usando as units nativas do Delphi e/ou Lazarus (NetHTTP e Indy), usando como base o projeto [RestRequest4Delphi](https://github.com/viniciussanchez/RESTRequest4Delphi)
43 |
44 | - Mais recursos serão implementados no futuro (e com ajuda de quem quiser colaborar com este projeto)
45 |
46 | ## Documentação e Demos
47 |
48 | Estou disponibilizando um Demo que demonstra a maioria (na verdade praticamente todos) dos recursos implementados. Em breve vou atualizar este Readme com mais informações de como usar esta biblioteca.
49 |
50 | ## Instalação
51 |
52 | Basta baixar os arquivos e adicionar ao seu projeto ou se desejar utilize o [Boss](https://github.com/HashLoad/boss) para adicionar ao seu projeto.
53 |
54 | # Versão
55 |
56 | **[eFirebase versão 1.1.1](/../../releases/latest)**
57 |
--------------------------------------------------------------------------------
/source/FirebaseLib/Response Classes/eFirebase.Responses.Storage.pas:
--------------------------------------------------------------------------------
1 | unit eFirebase.Responses.Storage;
2 |
3 | interface
4 |
5 | uses
6 | eFirebase.Interfaces;
7 |
8 | Type
9 | TeFirebaseStorageResponse = Class(TInterfacedObject, ieFirebaseStorageResponse)
10 | Private
11 | fdownloadTokens : string;
12 | fLink : string;
13 | fStatusCode : Integer;
14 | Public
15 | Constructor Create(const Response_content, url: string; StatusCode: integer);
16 | Destructor Destroy; Override;
17 | Class function New(const Response_content, url: string; StatusCode: integer): ieFirebaseStorageResponse;
18 | function Link : string;
19 | function StatusCode : Integer;
20 | End;
21 |
22 | implementation
23 |
24 | uses
25 | {$IFDEF FPC}
26 | fpjson, jsonparser;
27 | {$ELSE}
28 | System.JSON;
29 | {$ENDIF}
30 |
31 | { TeFirebaseStorageResponse }
32 |
33 | {$IFDEF FPC}
34 | function GetJSONData(const aJSON: UTF8String): TJSONData;
35 | var
36 | jParser: TJSONParser;
37 | begin
38 | Result := nil;
39 | jParser := TJSONParser.Create(aJSON, True);
40 | try
41 | Result := jParser.Parse;
42 | finally
43 | jParser.Free;
44 | end;
45 | end;
46 | {$ENDIF}
47 |
48 | constructor TeFirebaseStorageResponse.Create(const Response_content, url: string; StatusCode: integer);
49 | var
50 | {$IFDEF FPC}
51 | vJSON : TJSONData;
52 | gDownToken : TJSONString;
53 | {$ELSE}
54 | vJSON : TJSONValue;
55 | {$ENDIF}
56 | begin
57 | fStatusCode := StatusCode;
58 | fLink := '';
59 | fdownloadTokens := '';
60 |
61 | {$IFDEF FPC}
62 | vJSON := GetJSONData(Response_content);
63 |
64 | if (not Assigned(vJSON)) or (not (vJSON is TJSONObject)) then
65 | begin
66 | if Assigned(vJSON) then
67 | vJSON.Free;
68 | exit
69 | end;
70 |
71 | if TJSONObject(vJSON).Find('downloadTokens', gDownToken) then
72 | fDownloadTokens := gDownToken.AsJSON;
73 |
74 | if fStatusCode = 200 then
75 | fLink := url + '?alt=media&token=' + fdownloadTokens
76 | else
77 | fLink := '';
78 |
79 | if Assigned(vJSON) then
80 | vJSON.Free;
81 | {$ELSE}
82 | vJSON := TJSONObject.ParseJSONValue(Response_content);
83 |
84 | if (not Assigned(vJSON)) or (not (vJSON is TJSONObject)) then
85 | begin
86 | if Assigned(vJSON) then
87 | vJSON.DisposeOf;
88 | exit
89 | end;
90 |
91 | vJSON := vJSON as TJSONObject;
92 |
93 | vJSON.TryGetValue('downloadTokens', fDownloadTokens);
94 |
95 | if fStatusCode = 200 then
96 | fLink := url + '?alt=media&token=' + fdownloadTokens
97 | else
98 | fLink := '';
99 |
100 | if Assigned(vJSON) then
101 | vJSON.DisposeOf;
102 | {$ENDIF}
103 | end;
104 |
105 | destructor TeFirebaseStorageResponse.Destroy;
106 | begin
107 |
108 | inherited;
109 | end;
110 |
111 | function TeFirebaseStorageResponse.Link: string;
112 | begin
113 | Result := fLink;
114 | end;
115 |
116 | class function TeFirebaseStorageResponse.New(const Response_content, Url: string; StatusCode: integer): ieFirebaseStorageResponse;
117 | begin
118 | Result := Self.Create(Response_content, Url, StatusCode);
119 | end;
120 |
121 | function TeFirebaseStorageResponse.StatusCode: Integer;
122 | begin
123 | Result := fStatusCode;
124 | end;
125 |
126 | end.
127 |
--------------------------------------------------------------------------------
/source/eFirebase.Interfaces.pas:
--------------------------------------------------------------------------------
1 | unit eFirebase.Interfaces;
2 |
3 | interface
4 |
5 | uses
6 | eFirebase.Types,
7 | {$IFDEF FPC}
8 | fpjson,
9 | Classes;
10 | {$ELSE}
11 | System.Classes,
12 | System.JSON;
13 | {$ENDIF}
14 |
15 | type
16 |
17 | {$region 'Response Interfaces'}
18 | ieFirebaseResponseAuth = interface
19 | ['{0C91022C-E81B-4F8F-8849-129AA30D44E0}']
20 | function uID: string;
21 | function token: string;
22 | function RefreshToken: string;
23 | function ExpiresIn: integer;
24 | function Registered: Boolean;
25 | function Error: enumAuthErrors;
26 | function StatusCode: integer;
27 | function DisplayName: string;
28 | function Email: string;
29 | function EmailVerified: Boolean;
30 | function photoUrl: string;
31 | function lastLoginAt: string;
32 | function createdAt: string;
33 | end;
34 |
35 | ieFirebaseStorageResponse = interface
36 | ['{0E922EFE-715B-4848-8A43-B9F4C41E3AD4}']
37 | function Link : string;
38 | function StatusCode : Integer;
39 | end;
40 |
41 | ieFirebaseRealtimeResponse = interface
42 | ['{ACB9DD87-63DB-4F5C-AE93-E56096560FAB}']
43 | function StatusCode: integer;
44 | function ETag: string;
45 | function AsJSONstr: string;
46 | function AsJSONObj: tJSONObject;
47 | function AsJSONArray: TJSONArray;
48 | end;
49 | {$Endregion}
50 |
51 | {$Region 'Firebase Services'}
52 | ieFirebaseAuth = interface
53 | ['{FC27DC8A-3244-4384-880E-DCD0E5FC6F3E}']
54 | function SignUpWithEmailPassword(const email, password: string): ieFirebaseResponseAuth;
55 | function SignInWithEmailPassword(const email, password: string): ieFirebaseResponseAuth;
56 | function ExchangeRefreshToken4idToken(const RefreshToken: string): ieFirebaseResponseAuth;
57 | function SendPasswordResetEmail(const email: string): ieFirebaseResponseAuth;
58 | function VerifyPasswordResetCode(const oobCode: string): ieFirebaseResponseAuth;
59 | function ConfirmPasswordReset(const oobCode, newPassword: string): ieFirebaseResponseAuth;
60 | function SendEmailVerification(const token: string): ieFirebaseResponseAuth;
61 | function ConfirmEmailVerification(const oobCode: string): ieFirebaseResponseAuth;
62 | function DeleteAccount(const Token: string): ieFirebaseResponseAuth;
63 | function ChangePassword(const Token, newPassword: string): ieFirebaseResponseAuth;
64 | function ChangeProfile(const Token, DisplayName, PhotoURL: string): ieFirebaseResponseAuth;
65 | function GetProfile(const Token: string): ieFirebaseResponseAuth;
66 | end;
67 |
68 | ieFirebaseRealtimeFilters = interface
69 | ['{4457A621-512A-4AA0-A09D-258AA0AA5B59}']
70 | function OrderBy(const kind: eFirebaseOrderByKind): ieFirebaseRealtimeFilters; overload;
71 | function OrderBy(const fields: string): ieFirebaseRealtimeFilters; overload;
72 | function startAt(const value: string): ieFirebaseRealtimeFilters; overload;
73 | function starAt(const value: integer): ieFirebaseRealtimeFilters; overload;
74 | function endAt(const value: string): ieFirebaseRealtimeFilters; overload;
75 | function endAt(const value: integer): ieFirebaseRealtimeFilters; overload;
76 | function equalTo(const value: string): ieFirebaseRealtimeFilters; overload;
77 | function equalTo(const value: integer): ieFirebaseRealtimeFilters; overload;
78 | function limitToFirst(const value: integer): ieFirebaseRealtimeFilters;
79 | function limitToLast(const value: integer): ieFirebaseRealtimeFilters;
80 | function Search: ieFirebaseRealtimeResponse;
81 | end;
82 |
83 | ieFirebaseRealtime = interface
84 | ['{8B841477-098C-48A7-80C3-4EE8F43CA10B}']
85 | function AccessToken(const Token: string): ieFirebaseRealtime;
86 | function Endpoint(const url_path: string): ieFirebaseRealtime;
87 | function Collection(const name: string): ieFirebaseRealtime;
88 | function ReadWithoutFilters(const id: string = ''): ieFirebaseRealtimeResponse;
89 | function Read: ieFirebaseRealtimeFilters;
90 | function CreateRegister(const body: string): ieFirebaseRealtimeResponse;
91 | function UpdateRegister(const body: string; id: string = ''): ieFirebaseRealtimeResponse;
92 | function WriteRegister(const body: string; Etag: string = ''): ieFirebaseRealtimeResponse;
93 | function DeleteRegister(const id: string = ''; Etag: string = ''): ieFirebaseRealtimeResponse;
94 | end;
95 |
96 | ieFirebaseStorage = interface
97 | ['{FFD23146-5A08-4EE0-B648-2FA971D3FB63}']
98 | function Folder(const name: string) : ieFirebaseStorage;
99 | function FileName(const name: string) : ieFirebaseStorage;
100 | function Send(const AuthToken: string) : ieFirebaseStorageResponse;
101 | end;
102 | {$EndRegion}
103 |
104 | ieFirebase = interface
105 | ['{A03D3BFF-4A46-41E2-A9F0-41CC2979FAF7}']
106 | function Auth(const API_Key: string): ieFirebaseAuth;
107 | function RealTimeDB(const ProjectCode: string): ieFirebaseRealtime;
108 | function Storage(const ProjectCode: string): ieFirebaseStorage;
109 | end;
110 |
111 | implementation
112 |
113 | end.
114 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | * Demonstrating empathy and kindness toward other people
21 | * Being respectful of differing opinions, viewpoints, and experiences
22 | * Giving and gracefully accepting constructive feedback
23 | * Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | * Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | * The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | * Trolling, insulting or derogatory comments, and personal or political attacks
33 | * Public or private harassment
34 | * Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | * Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported to the community leaders responsible for enforcement at
63 | .
64 | All complaints will be reviewed and investigated promptly and fairly.
65 |
66 | All community leaders are obligated to respect the privacy and security of the
67 | reporter of any incident.
68 |
69 | ## Enforcement Guidelines
70 |
71 | Community leaders will follow these Community Impact Guidelines in determining
72 | the consequences for any action they deem in violation of this Code of Conduct:
73 |
74 | ### 1. Correction
75 |
76 | **Community Impact**: Use of inappropriate language or other behavior deemed
77 | unprofessional or unwelcome in the community.
78 |
79 | **Consequence**: A private, written warning from community leaders, providing
80 | clarity around the nature of the violation and an explanation of why the
81 | behavior was inappropriate. A public apology may be requested.
82 |
83 | ### 2. Warning
84 |
85 | **Community Impact**: A violation through a single incident or series
86 | of actions.
87 |
88 | **Consequence**: A warning with consequences for continued behavior. No
89 | interaction with the people involved, including unsolicited interaction with
90 | those enforcing the Code of Conduct, for a specified period of time. This
91 | includes avoiding interactions in community spaces as well as external channels
92 | like social media. Violating these terms may lead to a temporary or
93 | permanent ban.
94 |
95 | ### 3. Temporary Ban
96 |
97 | **Community Impact**: A serious violation of community standards, including
98 | sustained inappropriate behavior.
99 |
100 | **Consequence**: A temporary ban from any sort of interaction or public
101 | communication with the community for a specified period of time. No public or
102 | private interaction with the people involved, including unsolicited interaction
103 | with those enforcing the Code of Conduct, is allowed during this period.
104 | Violating these terms may lead to a permanent ban.
105 |
106 | ### 4. Permanent Ban
107 |
108 | **Community Impact**: Demonstrating a pattern of violation of community
109 | standards, including sustained inappropriate behavior, harassment of an
110 | individual, or aggression toward or disparagement of classes of individuals.
111 |
112 | **Consequence**: A permanent ban from any sort of public interaction within
113 | the community.
114 |
115 | ## Attribution
116 |
117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118 | version 2.0, available at
119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120 |
121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct
122 | enforcement ladder](https://github.com/mozilla/diversity).
123 |
124 | [homepage]: https://www.contributor-covenant.org
125 |
126 | For answers to common questions about this code of conduct, see the FAQ at
127 | https://www.contributor-covenant.org/faq. Translations are available at
128 | https://www.contributor-covenant.org/translations.
129 |
--------------------------------------------------------------------------------
/source/RestLib/eFirebase.request.pas:
--------------------------------------------------------------------------------
1 | unit eFirebase.request;
2 |
3 | interface
4 |
5 | uses
6 | eFirebase.request.contract,
7 | eFirebase.response.contract,
8 | REST.Client,
9 | System.Classes,
10 | eFirebase.Types,
11 | REST.Types;
12 |
13 | Type
14 | TRequest = Class(TInterfacedObject, iRequest)
15 | Private
16 | FResponse : iResponse;
17 | FRestRequest : tRESTRequest;
18 | FRestClient : tRESTClient;
19 | FRestResponse : tRESTResponse;
20 | FBody : string;
21 | Procedure DoJoinComponents;
22 | private
23 | function GetContentType(const ContentType: string): TRESTContentType;
24 | Public
25 | Constructor Create;
26 | Destructor Destroy; Override;
27 | Class function New: iRequest;
28 | function BaseUrl(Const BaseUrl: string): iRequest;
29 | function Resource(Const Resource : string): iRequest;
30 | function Body(const pbody: string): iRequest; overload;
31 | function Body(const pbody: TStream; const AOwns: Boolean): iRequest; overload;
32 | function SendFile(const FileName, ContentType: string):iRequest;
33 | function Token(Const pToken: string): iRequest;
34 | function AddParameter(const Key, Value: string):iRequest;
35 | function AddHeaders(const key, value: string):iRequest;
36 | function Get : iResponse;
37 | function Post : iResponse;
38 | function Patch : iResponse;
39 | function Delete : iResponse;
40 | function Put : iResponse;
41 | End;
42 |
43 | implementation
44 |
45 | { TRequest }
46 |
47 | Uses eFirebase.response;
48 |
49 | function TRequest.AddHeaders(const key, value: string): iRequest;
50 | begin
51 | Result := Self;
52 | // FRestRequest.Params.AddHeader(key, value);
53 | FRestRequest.Params.AddHeader(key, value);
54 | FRestRequest.Params.ParameterByName(key).Options := [poDoNotEncode];
55 | //FRestClient.AddParameter(key, value, TRESTRequestParameterKind.pkHTTPHEADER);
56 | end;
57 |
58 | function TRequest.AddParameter(const Key, Value: string): iRequest;
59 | begin
60 | Result := Self;
61 | FRestRequest.AddParameter(key, value, TRESTRequestParameterKind.pkQUERY);
62 | end;
63 |
64 | function TRequest.BaseUrl(const BaseUrl: string): iRequest;
65 | begin
66 | Result := self;
67 | FRestClient.BaseURL := BaseUrl;
68 | end;
69 |
70 | function TRequest.Body(const pbody: TStream; const AOwns: Boolean): iRequest;
71 | begin
72 | Result := Self;
73 | if not Assigned(pbody) then
74 | Exit;
75 | {$IF COMPILERVERSION <= 29}
76 | FRESTRequest.AddBody(pbody, TRESTContentType.ctAPPLICATION_OCTET_STREAM);
77 | {$ELSE}
78 | FRESTRequest.Body.Add(pbody, TRESTContentType.ctAPPLICATION_OCTET_STREAM);
79 | {$ENDIF}
80 | if AOwns then
81 | begin
82 | {$IFDEF MSWINDOWS}
83 | pbody.Free;
84 | {$ELSE}
85 | pbody.DisposeOf;
86 | {$ENDIF}
87 | end;
88 | end;
89 |
90 | function TRequest.Body(const pbody: string): iRequest;
91 | begin
92 | Result := Self;
93 | FBody := pbody;
94 | end;
95 |
96 | constructor TRequest.Create;
97 | begin
98 | FRestResponse := TRESTResponse.Create(nil);
99 | FRestClient := trestclient.Create(nil);
100 | FRestRequest := trestrequest.Create(nil);
101 | FResponse := tresponse.New(FRestResponse);
102 | DoJoinComponents;
103 | end;
104 |
105 | function TRequest.Delete: iResponse;
106 | begin
107 | Result := FResponse;
108 |
109 | FRestRequest.Method := trestrequestMethod.rmDELETE;
110 | FRestRequest.Execute;
111 | end;
112 |
113 | destructor TRequest.Destroy;
114 | begin
115 | FRestRequest.DisposeOf;
116 | FRestClient.DisposeOf;
117 | FRestResponse.DisposeOf;
118 | inherited;
119 | end;
120 |
121 | procedure TRequest.DoJoinComponents;
122 | begin
123 | FRestRequest.Client := FRestClient;
124 | FRestRequest.Response := FRestResponse;
125 | end;
126 |
127 | function TRequest.Get: iResponse;
128 | begin
129 | Result := FResponse;
130 |
131 | FRestRequest.Method := trestrequestMethod.rmGET;
132 | FRestRequest.Execute;
133 | end;
134 |
135 | function TRequest.GetContentType(const ContentType: string): TRESTContentType;
136 | begin
137 | if (ContentType = 'image/png') then
138 | Result := TRESTContentType.ctIMAGE_PNG
139 | else
140 | if (ContentType = 'image/gif') then
141 | Result := TRESTContentType.ctIMAGE_GIF
142 | else
143 | if (ContentType = 'image/jpg') or (ContentType = 'image/jpeg') then
144 | Result := TRESTContentType.ctIMAGE_JPEG
145 | else
146 | if (ContentType = 'text/plain') then
147 | Result := TRESTContentType.ctTEXT_PLAIN
148 | else
149 | if (ContentType = 'text/csv') then
150 | Result := TRESTContentType.ctTEXT_CSV
151 | else
152 | if (ContentType = 'text/css') then
153 | Result := TRESTContentType.ctTEXT_CSS
154 | else
155 | if (ContentType = 'application/pdf') then
156 | Result := TRESTContentType.ctAPPLICATION_PDF
157 | else
158 | if (ContentType = 'audio/mp3') then
159 | Result := TRESTContentType.ctAUDIO_MPEG
160 | else
161 | if (ContentType = 'audio/ogg') then
162 | Result := TRESTContentType.ctAUDIO_OGG
163 | else
164 | Result := TRESTContentType.ctAPPLICATION_OCTET_STREAM;
165 | end;
166 |
167 | class function TRequest.New: iRequest;
168 | begin
169 | Result := Self.Create;
170 | end;
171 |
172 | function TRequest.Patch: iResponse;
173 | begin
174 | Result := FResponse;
175 |
176 | FRestRequest.AddBody(FBody, TRESTContentType.ctAPPLICATION_JSON);
177 |
178 | FRestRequest.Method := trestrequestMethod.rmPATCH;
179 | FRestRequest.Execute;
180 | end;
181 |
182 | function TRequest.Post: iResponse;
183 | var
184 | teste: string;
185 | begin
186 | FRestRequest.AddBody(FBody, TRESTContentType.ctAPPLICATION_JSON);
187 |
188 | FRestRequest.Method := trestrequestMethod.rmPOST;
189 | teste := FRestRequest.GetFullRequestURL(true);
190 | FRestRequest.Execute;
191 |
192 | Result := FResponse;
193 | end;
194 |
195 | function TRequest.Put: iResponse;
196 | begin
197 | Result := FResponse;
198 |
199 | FRestRequest.AddBody(FBody, TRESTContentType.ctAPPLICATION_JSON);
200 |
201 | FRestRequest.Method := trestrequestMethod.rmPUT;
202 | FRestRequest.Execute;
203 | end;
204 |
205 | function TRequest.Resource(const Resource: string): iRequest;
206 | begin
207 | Result := self;
208 | FRestRequest.Resource := Resource;
209 | end;
210 |
211 | function TRequest.SendFile(const FileName, ContentType: string): iRequest;
212 | begin
213 | Result := Self;
214 | FRestRequest.AddFile(FileName, GetContentType(ContentType));
215 | end;
216 |
217 | function TRequest.Token(const pToken: string): iRequest;
218 | begin
219 | if pToken <> '' then
220 | begin
221 | FRestRequest.AddParameter('auth', pToken, TRESTRequestParameterKind.pkQUERY);
222 | Result := Self;
223 | end
224 | else
225 | Result := Self;
226 | end;
227 |
228 | end.
229 |
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/SimpleDemo.lps:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/backup/SimpleDemo.lps:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
--------------------------------------------------------------------------------
/source/RestLib/eFirebase.request.lazarus.pas:
--------------------------------------------------------------------------------
1 | unit eFirebase.request.lazarus;
2 |
3 | {$IFDEF FPC}
4 | {$mode delphi}
5 | {$ENDIF}
6 |
7 | interface
8 |
9 | uses
10 | eFirebase.request.contract,
11 | eFirebase.response.contract,
12 | idHTTP,
13 | Classes,
14 | IdSSLOpenSSL,
15 | IdSSLOpenSSLHeaders,
16 | IdMultipartFormData;
17 |
18 | Type
19 | TMethodRequest = (mrGET, mrPOST, mrPUT, mrPATCH, mrDELETE);
20 |
21 | TRequestLazarus = Class(TInterfacedObject, iRequest)
22 | Private
23 | FidHTTP : tidHTTP;
24 | FIdMultiPartFormDataStream: TIdMultiPartFormDataStream;
25 | FBaseURL : string;
26 | FResource : string;
27 | FResponse : iResponse;
28 | FStreamResult : tstringStream;
29 | FParams : TStrings;
30 | FBody : TStream;
31 | FIdSSLIOHandlerSocketOpenSSL : TIdSSLIOHandlerSocketOpenSSL;
32 | Function ExecuteRequest(Method: tMethodRequest): iRequest;
33 | function MakeUrl: string;
34 | Public
35 | Constructor Create;
36 | Destructor Destroy; Override;
37 | Class function New: iRequest;
38 | function BaseUrl(Const BaseUrl: string): iRequest;
39 | function Resource(Const Resource: string): iRequest;
40 | function Body(const pbody: string): iRequest; overload;
41 | function Body(const pbody: TStream; const AOwns: Boolean): iRequest; overload;
42 | function SendFile(const FileName, ContentType: string):iRequest;
43 | function Token(Const pToken: string): iRequest;
44 | function AddParameter(const Key, Value: string):iRequest;
45 | function AddHeaders(const key, value: string):iRequest;
46 | function Get : iResponse;
47 | function Post : iResponse;
48 | function Patch : iResponse;
49 | function Delete : iResponse;
50 | function Put : iResponse;
51 | End;
52 |
53 | implementation
54 |
55 | uses
56 | eFirebase.response.lazarus, SysUtils, idURI;
57 |
58 | { TRequestLazarus }
59 |
60 | function TRequestLazarus.AddHeaders(const key, value: string): iRequest;
61 | begin
62 | Result := Self;
63 | if FidHTTP.Request.CustomHeaders.indexof(key) < 0 then
64 | FidHTTP.Request.CustomHeaders.AddValue(key, value);
65 | end;
66 |
67 | function TRequestLazarus.AddParameter(const Key, Value: string): iRequest;
68 | begin
69 | Result := Self;
70 | FParams.Add(Key + '=' + Value);
71 | end;
72 |
73 | function TRequestLazarus.BaseUrl(const BaseUrl: string): iRequest;
74 | begin
75 | Result := Self;
76 | FBaseURL := BaseUrl;
77 | end;
78 |
79 | function TRequestLazarus.Body(const pbody: TStream; const AOwns: Boolean): iRequest;
80 | begin
81 | Result := Self;
82 | try
83 | if not Assigned(FBody) then
84 | FBody := TStringStream.Create;
85 | TStringStream(FBody).CopyFrom(pbody, pbody.Size);
86 | FBody.Position := 0;
87 | finally
88 | if AOwns then
89 | begin
90 | {$IF DEFINED(MSWINDOWS) OR DEFINED(FPC)}
91 | pbody.Free;
92 | {$ELSE}
93 | pbody.DisposeOf;
94 | {$ENDIF}
95 | end;
96 | end;
97 | end;
98 |
99 | function TRequestLazarus.Body(const pbody: string): iRequest;
100 | begin
101 | Result := Self;
102 | if not Assigned(FBody) then
103 | FBody := TStringStream.Create(pbody, TEncoding.UTF8)
104 | else
105 | TStringStream(FBody).WriteString(pbody);
106 | FBody.Position := 0;
107 | end;
108 |
109 | constructor TRequestLazarus.Create;
110 | begin
111 | FidHTTP := TIdHTTP.Create(nil);
112 | FidHTTP.Request.Connection := 'Keep-Alive';
113 | FidHTTP.Request.UserAgent := 'User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36';
114 | FidHTTP.HandleRedirects := true;
115 |
116 | FIdSSLIOHandlerSocketOpenSSL := TIdSSLIOHandlerSocketOpenSSL.Create;
117 | FIdHTTP.IOHandler := FIdSSLIOHandlerSocketOpenSSL;
118 | FIdSSLIOHandlerSocketOpenSSL.SSLOptions.SSLVersions := [sslvTLSv1, sslvTLSv1_1, sslvTLSv1_2];
119 |
120 | FResponse := tResponseLazarus.new(FidHTTP);
121 |
122 | FStreamResult := TStringStream.Create;
123 |
124 | Self.AddHeaders('Content-Type', 'application/json');
125 |
126 | FIdMultiPartFormDataStream := TIdMultiPartFormDataStream.Create;
127 |
128 | FParams := TStringList.Create;
129 |
130 | FIdHTTP.HTTPOptions:= [hoKeepOrigProtocol];
131 | end;
132 |
133 | function TRequestLazarus.Delete: iResponse;
134 | begin
135 | Result := FResponse;
136 | ExecuteRequest(mrDELETE);
137 | end;
138 |
139 | destructor TRequestLazarus.Destroy;
140 | begin
141 | FreeAndNil(FidHTTP);
142 | FreeAndNil(FIdSSLIOHandlerSocketOpenSSL);
143 | FreeAndNil(FParams);
144 | FreeAndNil(FStreamResult);
145 | if Assigned(FBody) then
146 | FreeAndNil(FBody);
147 | if Assigned(FIdMultiPartFormDataStream) then
148 | FreeAndNil(FIdMultiPartFormDataStream);
149 | inherited;
150 | end;
151 |
152 | function TRequestLazarus.ExecuteRequest(Method: tMethodRequest): iRequest;
153 | begin
154 | Result := Self;
155 | case Method of
156 | mrGET:
157 | begin
158 | FidHTTP.Get(tidURI.URLEncode(MakeURL), FStreamResult);
159 | end;
160 | mrPOST:
161 | begin
162 | if (Assigned(FIdMultiPartFormDataStream) and (FIdMultiPartFormDataStream.Size > 0)) then
163 | FIdHTTP.Post(TIdURI.URLEncode(MakeURL), FIdMultiPartFormDataStream, FStreamResult)
164 | else
165 | FidHTTP.Post(tidURI.URLEncode(MakeURL), FBody, FStreamResult);
166 | end;
167 | mrPUT:
168 | begin
169 | FidHTTP.Put(tidURI.URLEncode(MakeURL), FBody, FStreamResult);
170 | end;
171 | mrPATCH:
172 | begin
173 | FidHTTP.Patch(tidURI.URLEncode(MakeURL), FBody, FStreamResult);
174 | end;
175 | mrDELETE:
176 | begin
177 | FidHTTP.Delete(tidURI.URLEncode(MakeURL), FStreamResult);
178 | end;
179 | end;
180 | end;
181 |
182 | function TRequestLazarus.Get: iResponse;
183 | begin
184 | Result := FResponse;
185 | ExecuteRequest(mrGET);
186 | end;
187 |
188 | function TRequestLazarus.MakeUrl: string;
189 | var Param: integer;
190 | begin
191 | if FResource <> EmptyStr then
192 | Result := FBaseURL + '/' + FResource
193 | else
194 | Result := FBaseURL;
195 |
196 | if FParams.Count > 0 then
197 | begin
198 | Result := Result + '?';
199 | for Param := 0 to Pred(FParams.Count) do
200 | begin
201 | if Param > 0 then
202 | Result := Result + '&';
203 | Result := Result + FParams.Strings[Param];
204 | end;
205 | end;
206 | end;
207 |
208 | class function TRequestLazarus.New: iRequest;
209 | begin
210 | Result := Self.Create;
211 | end;
212 |
213 | function TRequestLazarus.Patch: iResponse;
214 | begin
215 | Result := FResponse;
216 | ExecuteRequest(mrPATCH);
217 | end;
218 |
219 | function TRequestLazarus.Post: iResponse;
220 | begin
221 | Result := FResponse;
222 | ExecuteRequest(mrPOST);
223 | end;
224 |
225 | function TRequestLazarus.Put: iResponse;
226 | begin
227 | Result := FResponse;
228 | ExecuteRequest(mrPUT);
229 | end;
230 |
231 | function TRequestLazarus.Resource(const Resource: string): iRequest;
232 | begin
233 | Result := Self;
234 | FResource := Resource;
235 | end;
236 |
237 | function TRequestLazarus.SendFile(const FileName, ContentType: string): iRequest;
238 | begin
239 | Result := Self;
240 | if not FileExists(FileName) then
241 | Exit;
242 | FIdMultiPartFormDataStream.AddFile('data', FileName, ContentType);
243 | end;
244 |
245 | function TRequestLazarus.Token(const pToken: string): iRequest;
246 | begin
247 | Result := Self;
248 | FParams.Add('auth=' + pToken);
249 | end;
250 |
251 | end.
252 |
--------------------------------------------------------------------------------
/Demos/Delphi/Simple Demo - FMX/UnitMain.vlb:
--------------------------------------------------------------------------------
1 | [Layout3]
2 | Coordinates=386,306,60,36
3 |
4 | [bLimparSenha]
5 | Coordinates=278,306,98,36
6 |
7 | [LabelPass]
8 | Coordinates=421,10,75,58
9 |
10 | [Label2]
11 | Coordinates=122,10,53,58
12 |
13 | [eUserEmail]
14 | Coordinates=185,10,81,58
15 |
16 | [MemoLog]
17 | Coordinates=357,78,71,58
18 |
19 | [Label1]
20 | Coordinates=294,78,53,58
21 |
22 | [Layout2]
23 | Coordinates=208,306,60,36
24 |
25 | [TabPass]
26 | Coordinates=133,306,65,36
27 |
28 | [TabFirebaseAuth]
29 | Coordinates=10,306,113,36
30 |
31 | [bRefreshToken]
32 | Coordinates=10,10,102,58
33 |
34 | [Layout1]
35 | Coordinates=443,260,60,36
36 |
37 | [bExibeSenha]
38 | Coordinates=342,260,91,36
39 |
40 | [TabProfile]
41 | Coordinates=259,260,73,36
42 |
43 | [grLog]
44 | Coordinates=276,10,47,58
45 |
46 | [TabRegistrar]
47 | Coordinates=160,260,89,36
48 |
49 | [TabLogin]
50 | Coordinates=82,260,68,36
51 |
52 | [ePassword]
53 | Coordinates=333,10,78,58
54 |
55 | [LayUser]
56 | Coordinates=10,260,62,36
57 |
58 | [TabControl1]
59 | Coordinates=382,214,85,36
60 |
61 | [LRefreshToken]
62 | Coordinates=93,78,102,58
63 |
64 | [bEntrar]
65 | Coordinates=438,78,57,58
66 |
67 | [TabFirebaseStorage]
68 | Coordinates=240,214,132,36
69 |
70 | [LaySenha]
71 | Coordinates=158,214,72,36
72 |
73 | [LToken]
74 | Coordinates=10,146,57,58
75 | Visible=True
76 | LayerNames=
77 |
78 | [TabFirebaseRealtime]
79 | Coordinates=10,214,138,36
80 |
81 | [LabelUser]
82 | Coordinates=10,78,73,58
83 |
84 | [TabDelAccount]
85 | Coordinates=361,146,102,36
86 |
87 | [TabServices]
88 | Coordinates=265,146,86,36
89 |
90 | [TabVerEmail]
91 | Coordinates=166,146,89,36
92 |
93 | []
94 | Coordinates=1150,750,46,58
95 | Visible=True
96 |
97 | [Module Settings]
98 | ModelLayerNames=
99 | ActiveLayerNames=
100 | EditingLayerName=
101 |
102 | [grEfetuarLogin]
103 | Coordinates=77,146,99,58
104 |
105 | [grToken]
106 | Coordinates=205,78,62,58
107 |
108 | [LSenhaReg]
109 | Coordinates=749,78,82,58
110 |
111 | [Label15]
112 | Coordinates=730,539,60,58
113 |
114 | [Label20]
115 | Coordinates=908,155,60,58
116 |
117 | [PasswordEditButton1]
118 | Coordinates=1231,1,137,36
119 |
120 | [eCodeEmailVerify]
121 | Coordinates=27,347,118,58
122 |
123 | [Layout21]
124 | Coordinates=681,635,67,36
125 |
126 | [Layout8]
127 | Coordinates=612,635,60,36
128 |
129 | [ESenhaRegistro]
130 | Coordinates=305,347,108,58
131 |
132 | [bTrocaSenha]
133 | Coordinates=597,78,91,58
134 |
135 | [Layout12]
136 | Coordinates=543,635,67,36
137 |
138 | [Layout16]
139 | Coordinates=474,635,67,36
140 |
141 | [Layout10]
142 | Coordinates=405,635,67,36
143 |
144 | [GrRegistrar]
145 | Coordinates=355,539,81,58
146 |
147 | [ePastaStorage]
148 | Coordinates=799,731,99,58
149 |
150 | [Layout26]
151 | Coordinates=336,635,67,36
152 |
153 | [Layout20]
154 | Coordinates=267,635,67,36
155 |
156 | [GroupBox2]
157 | Coordinates=486,380,79,58
158 |
159 | [Layout22]
160 | Coordinates=198,635,67,36
161 |
162 | [Layout7]
163 | Coordinates=129,635,60,36
164 |
165 | [LCreatedAt]
166 | Coordinates=449,87,79,58
167 |
168 | [WebBrowser1]
169 | Coordinates=30,635,95,36
170 |
171 | [Label17]
172 | Coordinates=44,443,60,58
173 |
174 | [Layout14]
175 | Coordinates=1020,78,67,36
176 |
177 | [eOOBCodeReset]
178 | Coordinates=597,386,114,58
179 |
180 | [Button1]
181 | Coordinates=749,309,59,58
182 |
183 | [eEndPoint]
184 | Coordinates=749,463,74,58
185 |
186 | [lEmailVerificado]
187 | Coordinates=157,539,107,58
188 |
189 | [LuID]
190 | Coordinates=0,481,42,58
191 |
192 | [Label11]
193 | Coordinates=908,78,60,58
194 |
195 | [Layout9]
196 | Coordinates=1020,133,60,36
197 |
198 | [Label13]
199 | Coordinates=602,539,60,58
200 |
201 | [eCollection]
202 | Coordinates=463,731,79,58
203 |
204 | [Label21]
205 | Coordinates=261,1,60,58
206 |
207 | [GroupBox4]
208 | Coordinates=261,87,79,58
209 |
210 | [bConfNovaSenhaReset]
211 | Coordinates=146,347,149,58
212 |
213 | [eTask]
214 | Coordinates=908,617,49,58
215 |
216 | [Label12]
217 | Coordinates=908,1,60,58
218 |
219 | [Layout27]
220 | Coordinates=1020,188,67,36
221 |
222 | [Button3]
223 | Coordinates=908,309,59,58
224 |
225 | [Label4]
226 | Coordinates=631,731,53,58
227 |
228 | [bVerificarOOBCodeResetar]
229 | Coordinates=1020,1,173,58
230 |
231 | [ClearEditButton2]
232 | Coordinates=1231,56,112,36
233 |
234 | [ClearEditButton1]
235 | Coordinates=1231,111,112,36
236 |
237 | [bLerProfile]
238 | Coordinates=81,251,77,58
239 |
240 | [Layout30]
241 | Coordinates=1020,243,67,36
242 |
243 | [chDone]
244 | Coordinates=0,0,65,58
245 |
246 | [Label9]
247 | Coordinates=908,540,53,58
248 |
249 | [Layout28]
250 | Coordinates=1020,298,67,36
251 |
252 | [LTokenReg]
253 | Coordinates=908,694,81,58
254 |
255 | [GroupBox8]
256 | Coordinates=176,731,79,58
257 |
258 | [ListBox1]
259 | Coordinates=84,1,139,212
260 |
261 | [PasswordEditButton2]
262 | Coordinates=1231,166,137,36
263 |
264 | [Layout4]
265 | Coordinates=1020,353,60,36
266 |
267 | [Label10]
268 | Coordinates=908,386,60,58
269 |
270 | [Label18]
271 | Coordinates=414,318,60,58
272 |
273 | [bNavegar]
274 | Coordinates=518,443,70,58
275 |
276 | [LRefTokenReg]
277 | Coordinates=749,155,101,58
278 |
279 | [bEnviarArquivo]
280 | Coordinates=690,731,102,58
281 |
282 | [Layout29]
283 | Coordinates=1020,408,67,36
284 |
285 | [eNovaSenhaTroca]
286 | Coordinates=749,1,121,58
287 |
288 | [Layout23]
289 | Coordinates=1020,463,67,36
290 |
291 | [GrPerfil]
292 | Coordinates=749,386,59,58
293 |
294 | [Label8]
295 | Coordinates=22,251,53,58
296 |
297 | [eURLphoto]
298 | Coordinates=266,539,79,58
299 |
300 | [Layout25]
301 | Coordinates=1020,518,67,36
302 |
303 | [eCategory]
304 | Coordinates=908,463,74,58
305 |
306 | [bVerificarEmail]
307 | Coordinates=597,309,102,58
308 |
309 | [bApagarConta]
310 | Coordinates=58,539,97,58
311 |
312 | [bEnviarcodigo]
313 | Coordinates=265,731,96,58
314 |
315 | [bRegistrar]
316 | Coordinates=552,731,74,58
317 |
318 | [Label5]
319 | Coordinates=261,241,53,58
320 |
321 | [lUserEmailReg]
322 | Coordinates=202,443,100,58
323 |
324 | [Label14]
325 | Coordinates=597,232,60,58
326 |
327 | [eSenhaReset]
328 | Coordinates=364,731,92,58
329 |
330 | [Label6]
331 | Coordinates=749,232,53,58
332 |
333 | [Label16]
334 | Coordinates=597,155,60,58
335 |
336 | [Layout13]
337 | Coordinates=1020,573,67,36
338 |
339 | [Label3]
340 | Coordinates=459,443,53,58
341 |
342 | [GroupBox6]
343 | Coordinates=505,1,79,58
344 |
345 | [Layout11]
346 | Coordinates=1020,628,67,36
347 |
348 | [GroupBox7]
349 | Coordinates=750,635,79,58
350 |
351 | [eEmailRegistro]
352 | Coordinates=622,463,102,58
353 |
354 | [eDisplayName]
355 | Coordinates=242,164,98,58
356 |
357 | [eArquivoStorage]
358 | Coordinates=449,241,110,58
359 |
360 | [GroupBox5]
361 | Coordinates=87,731,79,58
362 |
363 | [ListBoxHeader1]
364 | Coordinates=1020,683,106,36
365 |
366 | [eEmailReset]
367 | Coordinates=370,443,87,58
368 |
369 | [Label19]
370 | Coordinates=597,1,60,58
371 |
372 | [GroupBox1]
373 | Coordinates=113,443,79,58
374 |
375 | [Layout18]
376 | Coordinates=1001,731,67,36
377 |
378 | [PasswordEditButton3]
379 | Coordinates=1231,221,137,36
380 |
381 | [Layout24]
382 | Coordinates=18,731,67,36
383 |
384 | [bResetarSenha]
385 | Coordinates=449,164,104,58
386 |
387 | [Label7]
388 | Coordinates=311,443,53,58
389 |
390 | [SelectFile]
391 | Coordinates=1231,276,71,36
392 |
393 | [Layout19]
394 | Coordinates=1231,331,67,36
395 |
396 | [BSearchFile]
397 | Coordinates=1231,386,85,36
398 |
399 | [LEmail]
400 | Coordinates=671,539,54,58
401 |
402 | [Layout5]
403 | Coordinates=1231,441,60,36
404 |
405 | [Layout17]
406 | Coordinates=1231,496,67,36
407 |
408 | [Layout15]
409 | Coordinates=1231,551,67,36
410 |
411 | [ClearEditButton3]
412 | Coordinates=1231,606,112,36
413 |
414 | [Layout6]
415 | Coordinates=1231,661,60,36
416 |
417 | [LLastAccess]
418 | Coordinates=513,539,87,58
419 |
420 | [GroupBox3]
421 | Coordinates=505,318,79,58
422 |
423 | [bReadCollection]
424 | Coordinates=444,539,59,58
425 |
426 | [bAddRecord]
427 | Coordinates=908,232,59,58
428 |
429 | [bUpdateRecord]
430 | Coordinates=15,77,59,58
431 |
432 | [bDeleteRecord]
433 | Coordinates=839,635,59,58
434 |
435 |
--------------------------------------------------------------------------------
/source/FirebaseLib/eFirebase.Auth.pas:
--------------------------------------------------------------------------------
1 | unit eFirebase.Auth;
2 |
3 | interface
4 |
5 | uses
6 | eFirebase.Interfaces;
7 |
8 | type
9 |
10 | TeFirebaseAuth = Class(TInterfacedObject, ieFirebaseAuth)
11 | Private
12 | fAPI_Key: string;
13 | Public
14 | Constructor Create(const API_Key: string);
15 | Destructor Destroy; Override;
16 | Class function New(const API_Key: string): ieFirebaseAuth;
17 | function SignUpWithEmailPassword(const email, password: string): ieFirebaseResponseAuth;
18 | function SignInWithEmailPassword(const email, password: string): ieFirebaseResponseAuth;
19 | function ExchangeRefreshToken4idToken(const RefreshToken: string): ieFirebaseResponseAuth;
20 | function SendPasswordResetEmail(const email: string): ieFirebaseResponseAuth;
21 | function VerifyPasswordResetCode(const oobCode: string): ieFirebaseResponseAuth;
22 | function ConfirmPasswordReset(const oobCode, newPassword: string): ieFirebaseResponseAuth;
23 | function SendEmailVerification(const token: string): ieFirebaseResponseAuth;
24 | function ConfirmEmailVerification(const oobCode: string): ieFirebaseResponseAuth;
25 | function DeleteAccount(const Token: string): ieFirebaseResponseAuth;
26 | function ChangePassword(const Token, newPassword: string): ieFirebaseResponseAuth;
27 | function ChangeProfile(const Token, DisplayName, PhotoURL: string): ieFirebaseResponseAuth;
28 | function GetProfile(const Token: string): ieFirebaseResponseAuth;
29 | End;
30 |
31 | const
32 | SignUp_URL = 'https://identitytoolkit.googleapis.com/v1/accounts:signUp';
33 | SignIn_URL = 'https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword';
34 | SendPassRestEmail = 'https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode';
35 | SendEmailVerURL = 'https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode';
36 | SecureToken_URL = 'https://securetoken.googleapis.com/v1/token';
37 | PasswordReset = 'https://identitytoolkit.googleapis.com/v1/accounts:resetPassword';
38 | ConfirmEmail = 'https://identitytoolkit.googleapis.com/v1/accounts:update';
39 | DeleteAccountURL = 'https://identitytoolkit.googleapis.com/v1/accounts:delete';
40 | ChangePasswordURL = 'https://identitytoolkit.googleapis.com/v1/accounts:update';
41 | UpdateProfileURL = 'https://identitytoolkit.googleapis.com/v1/accounts:update';
42 | GetProfileURL = 'https://identitytoolkit.googleapis.com/v1/accounts:lookup';
43 |
44 | implementation
45 |
46 | uses
47 | eFirebase.Responses.Auth,
48 | {$IFDEF FPC}
49 | fpjson,
50 | {$ELSE}
51 | System.JSON,
52 | {$ENDIF}
53 | eFirebase.rest;
54 |
55 | { TeFirebaseAuth }
56 |
57 | function TeFirebaseAuth.ChangePassword(const Token, newPassword: string): ieFirebaseResponseAuth;
58 | var
59 | ResponseJSON: string;
60 | RequestBody: TJSONObject;
61 | RequestBodySTR: string;
62 | Response: iResponse;
63 | begin
64 | RequestBody := TJSONObject.Create;
65 | try
66 | {$IFDEF FPC}
67 | RequestBody.Add('idToken', Token);
68 | RequestBody.Add('password', newPassword);
69 | RequestBody.Add('returnSecureToken', True);
70 | RequestBodySTR := RequestBody.AsJSON;
71 | {$ELSE}
72 | RequestBody.AddPair('idToken', Token);
73 | RequestBody.AddPair('password', newPassword);
74 | RequestBody.AddPair('returnSecureToken', TJSONBool.Create(True));
75 | RequestBodySTR := RequestBody.ToString;
76 | {$ENDIF}
77 | finally
78 | {$IFDEF FPC}
79 | RequestBody.Free;
80 | {$ELSE}
81 | RequestBody.DisposeOf;
82 | {$ENDIF}
83 | end;
84 |
85 | Response := TRest.New
86 | .BaseUrl(ChangePasswordURL)
87 | .AddParameter('key', fAPI_Key)
88 | .Body(RequestBodySTR)
89 | .Post;
90 |
91 | ResponseJSON := Response.Content;
92 | Result := TeFirebaseResponseAuth.New(ResponseJSON, Response.StatusCode);
93 | end;
94 |
95 | function TeFirebaseAuth.ChangeProfile(const Token, DisplayName,PhotoURL: string): ieFirebaseResponseAuth;
96 | var
97 | ResponseJSON: string;
98 | RequestBody: TJSONObject;
99 | RequestBodySTR: string;
100 | Response: iResponse;
101 | begin
102 | RequestBody := TJSONObject.Create;
103 | try
104 | {$IFDEF FPC}
105 | RequestBody.Add('idToken', Token);
106 | RequestBody.Add('displayName', DisplayName);
107 | RequestBody.Add('photoUrl', PhotoURL);
108 | RequestBody.Add('returnSecureToken', True);
109 | RequestBodySTR := RequestBody.AsJSON;
110 | {$ELSE}
111 | RequestBody.AddPair('idToken', Token);
112 | RequestBody.AddPair('displayName', DisplayName);
113 | RequestBody.AddPair('photoUrl', PhotoURL);
114 | RequestBody.AddPair('returnSecureToken', TJSONBool.Create(True));
115 | RequestBodySTR := RequestBody.ToString;
116 | {$ENDIF}
117 | finally
118 | {$IFDEF FPC}
119 | RequestBody.Free;
120 | {$ELSE}
121 | RequestBody.DisposeOf;
122 | {$ENDIF}
123 | end;
124 |
125 | Response := TRest.New
126 | .BaseUrl(UpdateProfileUrl)
127 | .AddParameter('key', fAPI_Key)
128 | .Body(RequestBodySTR)
129 | .Post;
130 |
131 | ResponseJSON := Response.Content;
132 | Result := TeFirebaseResponseAuth.New(ResponseJSON, Response.StatusCode);
133 | end;
134 |
135 | function TeFirebaseAuth.ConfirmEmailVerification(const oobCode: string): ieFirebaseResponseAuth;
136 | var
137 | ResponseJSON: string;
138 | RequestBody: TJSONObject;
139 | RequestBodySTR: string;
140 | Response: iResponse;
141 | begin
142 | RequestBody := TJSONObject.Create;
143 | try
144 | {$IFDEF FPC}
145 | RequestBody.Add('oobCode', oobCode);
146 | RequestBodySTR := RequestBody.AsJSON;
147 | {$ELSE}
148 | RequestBody.AddPair('oobCode', oobCode);
149 | RequestBodySTR := RequestBody.ToString;
150 | {$ENDIF}
151 | finally
152 | {$IFDEF FPC}
153 | RequestBody.Free;
154 | {$ELSE}
155 | RequestBody.DisposeOf;
156 | {$ENDIF}
157 | end;
158 |
159 | Response := TRest.New
160 | .BaseUrl(ConfirmEmail)
161 | .AddParameter('key', fAPI_Key)
162 | .Body(RequestBodySTR)
163 | .Post;
164 |
165 | ResponseJSON := Response.Content;
166 | Result := TeFirebaseResponseAuth.New(ResponseJSON, Response.StatusCode);
167 | end;
168 |
169 | function TeFirebaseAuth.ConfirmPasswordReset(const oobCode, newPassword: string): ieFirebaseResponseAuth;
170 | var
171 | ResponseJSON: string;
172 | RequestBody: TJSONObject;
173 | RequestBodySTR: string;
174 | Response: iResponse;
175 | begin
176 | RequestBody := TJSONObject.Create;
177 | try
178 | {$IFDEF FPC}
179 | RequestBody.Add('oobCode', oobCode);
180 | RequestBody.Add('newPassword', newPassword);
181 | RequestBodySTR := RequestBody.AsJSON;
182 | {$ELSE}
183 | RequestBody.AddPair('oobCode', oobCode);
184 | RequestBody.AddPair('newPassword', newPassword);
185 | RequestBodySTR := RequestBody.ToString;
186 | {$ENDIF}
187 | finally
188 | {$IFDEF FPC}
189 | RequestBody.Free;
190 | {$ELSE}
191 | RequestBody.DisposeOf;
192 | {$ENDIF}
193 | end;
194 |
195 | Response := TRest.New
196 | .BaseUrl(PasswordReset)
197 | .AddParameter('key', fAPI_Key)
198 | .Body(RequestBodySTR)
199 | .Post;
200 |
201 | ResponseJSON := Response.Content;
202 | Result := TeFirebaseResponseAuth.New(ResponseJSON, Response.StatusCode);
203 | end;
204 |
205 | constructor TeFirebaseAuth.Create(const API_Key: string);
206 | begin
207 | fAPI_Key := API_Key;
208 | end;
209 |
210 | function TeFirebaseAuth.DeleteAccount(const Token: string): ieFirebaseResponseAuth;
211 | var
212 | ResponseJSON: string;
213 | RequestBody: TJSONObject;
214 | RequestBodySTR: string;
215 | Response: iResponse;
216 | begin
217 | RequestBody := TJSONObject.Create;
218 | try
219 | {$IFDEF FPC}
220 | RequestBody.Add('idToken', token);
221 | RequestBodySTR := RequestBody.AsJSON;
222 | {$ELSE}
223 | RequestBody.AddPair('idToken', token);
224 | RequestBodySTR := RequestBody.ToString;
225 | {$ENDIF}
226 | finally
227 | {$IFDEF FPC}
228 | RequestBody.Free;
229 | {$ELSE}
230 | RequestBody.DisposeOf;
231 | {$ENDIF}
232 | end;
233 |
234 | Response := TRest.New
235 | .BaseUrl(DeleteAccountURL)
236 | .AddParameter('key', fAPI_Key)
237 | .Body(RequestBodySTR)
238 | .Post;
239 |
240 | ResponseJSON := Response.Content;
241 | Result := TeFirebaseResponseAuth.New(ResponseJSON, Response.StatusCode);
242 | end;
243 |
244 | destructor TeFirebaseAuth.Destroy;
245 | begin
246 |
247 | inherited;
248 | end;
249 |
250 | function TeFirebaseAuth.ExchangeRefreshToken4idToken(const RefreshToken: string): ieFirebaseResponseAuth;
251 | var
252 | ResponseJSON: string;
253 | RequestBody: TJSONObject;
254 | RequestBodySTR: string;
255 | Response: iResponse;
256 | begin
257 | RequestBody := TJSONObject.Create;
258 | try
259 | {$IFDEF FPC}
260 | RequestBody.Add('grant_type', 'refresh_token');
261 | RequestBody.Add('refresh_token', RefreshToken);
262 | RequestBodySTR := RequestBody.AsJSON;
263 | {$ELSE}
264 | RequestBody.AddPair('grant_type', 'refresh_token');
265 | RequestBody.AddPair('refresh_token', RefreshToken);
266 | RequestBodySTR := RequestBody.ToString;
267 | {$ENDIF}
268 | finally
269 | {$IFDEF FPC}
270 | RequestBody.Free;
271 | {$ELSE}
272 | RequestBody.DisposeOf;
273 | {$ENDIF}
274 | end;
275 |
276 | Response := TRest.New
277 | .BaseUrl(SecureToken_URL)
278 | .AddParameter('key', fAPI_Key)
279 | .Body(RequestBodySTR)
280 | .Post;
281 |
282 | ResponseJSON := Response.Content;
283 | Result := TeFirebaseResponseAuth.New(ResponseJSON, Response.StatusCode);
284 | end;
285 |
286 | function TeFirebaseAuth.GetProfile(const Token: string): ieFirebaseResponseAuth;
287 | var
288 | ResponseJSON: string;
289 | RequestBody: TJSONObject;
290 | RequestBodySTR: string;
291 | Response: iResponse;
292 | begin
293 | RequestBody := TJSONObject.Create;
294 | try
295 | {$IFDEF FPC}
296 | RequestBody.Add('idToken', token);
297 | RequestBodySTR := RequestBody.AsJSON;
298 | {$ELSE}
299 | RequestBody.AddPair('idToken', token);
300 | RequestBodySTR := RequestBody.ToString;
301 | {$ENDIF}
302 | finally
303 | {$IFDEF FPC}
304 | RequestBody.Free;
305 | {$ELSE}
306 | RequestBody.DisposeOf;
307 | {$ENDIF}
308 | end;
309 |
310 | Response := TRest.New
311 | .BaseUrl(GetProfileURL)
312 | .AddParameter('key', fAPI_Key)
313 | .Body(RequestBodySTR)
314 | .Post;
315 |
316 | ResponseJSON := Response.Content;
317 | Result := TeFirebaseResponseAuth.New(ResponseJSON, Response.StatusCode);
318 | end;
319 |
320 | class function TeFirebaseAuth.New(const API_Key: string): ieFirebaseAuth;
321 | begin
322 | Result := Self.Create(API_Key);
323 | end;
324 |
325 | function TeFirebaseAuth.SendEmailVerification(const token: string): ieFirebaseResponseAuth;
326 | var
327 | ResponseJSON: string;
328 | RequestBody: TJSONObject;
329 | RequestBodySTR: string;
330 | Response: iResponse;
331 | begin
332 | RequestBody := TJSONObject.Create;
333 | try
334 | {$IFDEF FPC}
335 | RequestBody.Add('requestType', 'VERIFY_EMAIL');
336 | RequestBody.Add('idToken', token);
337 | RequestBodySTR := RequestBody.AsJSON;
338 | {$ELSE}
339 | RequestBody.AddPair('requestType', 'VERIFY_EMAIL');
340 | RequestBody.AddPair('idToken', token);
341 | RequestBodySTR := RequestBody.ToString;
342 | {$ENDIF}
343 | finally
344 | {$IFDEF FPC}
345 | RequestBody.Free;
346 | {$ELSE}
347 | RequestBody.DisposeOf;
348 | {$ENDIF}
349 | end;
350 |
351 | Response := TRest.New
352 | .BaseUrl(SendEmailVerURL)
353 | .AddParameter('key', fAPI_Key)
354 | .Body(RequestBodySTR)
355 | .Post;
356 |
357 | ResponseJSON := Response.Content;
358 | Result := TeFirebaseResponseAuth.New(ResponseJSON, Response.StatusCode);
359 | end;
360 |
361 | function TeFirebaseAuth.SendPasswordResetEmail(const email: string): ieFirebaseResponseAuth;
362 | var
363 | ResponseJSON: string;
364 | RequestBody: TJSONObject;
365 | RequestBodySTR: string;
366 | Response: iResponse;
367 | begin
368 | RequestBody := TJSONObject.Create;
369 | try
370 | {$IFDEF FPC}
371 | RequestBody.Add('requestType', 'PASSWORD_RESET');
372 | RequestBody.Add('email', email);
373 | RequestBodySTR := RequestBody.AsJSON;
374 | {$ELSE}
375 | RequestBody.AddPair('requestType', 'PASSWORD_RESET');
376 | RequestBody.AddPair('email', email);
377 | RequestBodySTR := RequestBody.ToString;
378 | {$ENDIF}
379 | finally
380 | {$IFDEF FPC}
381 | RequestBody.Free;
382 | {$ELSE}
383 | RequestBody.DisposeOf;
384 | {$ENDIF}
385 | end;
386 |
387 | Response := TRest.New
388 | .BaseUrl(SendPassRestEmail)
389 | .AddParameter('key', fAPI_Key)
390 | .Body(RequestBodySTR)
391 | .Post;
392 |
393 | ResponseJSON := Response.Content;
394 | Result := TeFirebaseResponseAuth.New(ResponseJSON, Response.StatusCode);
395 | end;
396 |
397 | function TeFirebaseAuth.SignInWithEmailPassword(const email, password: string): ieFirebaseResponseAuth;
398 | var
399 | ResponseJSON: string;
400 | RequestBody: TJSONObject;
401 | RequestBodySTR: string;
402 | Response: iResponse;
403 | begin
404 | RequestBody := TJSONObject.Create;
405 | try
406 | {$IFDEF FPC}
407 | RequestBody.Add('email', email);
408 | RequestBody.Add('password', password);
409 | RequestBody.Add('returnSecureToken', True);
410 | RequestBodySTR := RequestBody.AsJSON;
411 | {$ELSE}
412 | RequestBody.AddPair('email', email);
413 | RequestBody.AddPair('password', password);
414 | RequestBody.AddPair('returnSecureToken', TJSONBool.Create(True));
415 | RequestBodySTR := RequestBody.ToString;
416 | {$ENDIF}
417 | finally
418 | {$IFDEF FPC}
419 | RequestBody.Free;
420 | {$ELSE}
421 | RequestBody.DisposeOf;
422 | {$ENDIF}
423 | end;
424 |
425 | Response := TRest.New
426 | .BaseUrl(SignIn_URL)
427 | .AddParameter('key', fAPI_Key)
428 | .Body(RequestBodySTR)
429 | .Post;
430 |
431 | ResponseJSON := Response.Content;
432 | Result := TeFirebaseResponseAuth.New(ResponseJSON, Response.StatusCode);
433 | end;
434 |
435 | function TeFirebaseAuth.SignUpWithEmailPassword(const email, password: string): ieFirebaseResponseAuth;
436 | var
437 | ResponseJSON: string;
438 | RequestBody: TJSONObject;
439 | RequestBodySTR: string;
440 | Response: iResponse;
441 | begin
442 | RequestBody := TJSONObject.Create;
443 | try
444 | {$IFDEF FPC}
445 | RequestBody.Add('email', email);
446 | RequestBody.Add('password', password);
447 | RequestBody.Add('returnSecureToken', True);
448 | RequestBodySTR := RequestBody.AsJSON;
449 | {$ELSE}
450 | RequestBody.AddPair('email', email);
451 | RequestBody.AddPair('password', password);
452 | RequestBody.AddPair('returnSecureToken', TJSONBool.Create(True));
453 | RequestBodySTR := RequestBody.ToString;
454 | {$ENDIF}
455 | finally
456 | {$IFDEF FPC}
457 | RequestBody.Free;
458 | {$ELSE}
459 | RequestBody.DisposeOf;
460 | {$ENDIF}
461 | end;
462 |
463 | Response := TRest.New
464 | .BaseUrl(SignUp_URL)
465 | .AddParameter('key', fAPI_Key)
466 | .Body(RequestBodySTR)
467 | .Post;
468 |
469 | ResponseJSON := Response.Content;
470 | Result := TeFirebaseResponseAuth.New(ResponseJSON, Response.StatusCode);
471 | end;
472 |
473 | function TeFirebaseAuth.VerifyPasswordResetCode(const oobCode: string): ieFirebaseResponseAuth;
474 | var
475 | ResponseJSON: string;
476 | RequestBody: TJSONObject;
477 | RequestBodySTR: string;
478 | Response: iResponse;
479 | begin
480 | RequestBody := TJSONObject.Create;
481 | try
482 | {$IFDEF FPC}
483 | RequestBody.Add('oobCode', oobCode);
484 | RequestBodySTR := RequestBody.AsJSON;
485 | {$ELSE}
486 | RequestBody.AddPair('oobCode', oobCode);
487 | RequestBodySTR := RequestBody.ToString;
488 | {$ENDIF}
489 | finally
490 | {$IFDEF FPC}
491 | RequestBody.Free;
492 | {$ELSE}
493 | RequestBody.DisposeOf;
494 | {$ENDIF}
495 | end;
496 |
497 | Response := TRest.New
498 | .BaseUrl(PasswordReset)
499 | .AddParameter('key', fAPI_Key)
500 | .Body(RequestBodySTR)
501 | .Post;
502 |
503 | ResponseJSON := Response.Content;
504 | Result := TeFirebaseResponseAuth.New(ResponseJSON, Response.StatusCode);
505 | end;
506 |
507 | end.
508 |
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/unitmain.pas:
--------------------------------------------------------------------------------
1 | unit unitMain;
2 |
3 | {$mode objfpc}{$H+}
4 |
5 | interface
6 |
7 | uses
8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, StdCtrls,
9 | ExtCtrls, Grids, IpHtml, Types, fpjson;
10 |
11 | type
12 |
13 | { TFormMain }
14 |
15 | TFormMain = class(TForm)
16 | btEnviarArquivo: TButton;
17 | btnReadCollection: TButton;
18 | btnAddRecord: TButton;
19 | btnUpdateRecord: TButton;
20 | btnDeleteRecord: TButton;
21 | btProcurarArquivo: TButton;
22 | btTrocarSenha: TButton;
23 | btLoginEntrar: TButton;
24 | btAtualizarToken: TButton;
25 | btResetConfirmar: TButton;
26 | btResetResetar: TButton;
27 | btResetVerificar: TButton;
28 | btRegistroRegistrar: TButton;
29 | btExibirPerfil: TButton;
30 | btSalvarPerfil: TButton;
31 | btVerificarEmailEnviaCode: TButton;
32 | btVerificarEmailVerificaCode: TButton;
33 | btApagarConta: TButton;
34 | chFieldDone: TCheckBox;
35 | eStorageArquivo: TEdit;
36 | eRealtimeCollection: TEdit;
37 | eFieldTask: TEdit;
38 | eFieldCategory: TEdit;
39 | eStoragePasta: TEdit;
40 | eResetCode: TEdit;
41 | eResetNovaSenha: TEdit;
42 | ePerfilNome: TEdit;
43 | ePerfilURLFoto: TEdit;
44 | eRealtimeEndpoint: TEdit;
45 | eTrocarSenha: TEdit;
46 | eResetEmail: TEdit;
47 | eRegistroSenha: TEdit;
48 | eLoginUsername: TEdit;
49 | eLoginSenha: TEdit;
50 | eRegistroUsername: TEdit;
51 | eVerificarEmail: TEdit;
52 | GroupBox1: TGroupBox;
53 | GroupBox2: TGroupBox;
54 | GroupBox3: TGroupBox;
55 | GroupBox4: TGroupBox;
56 | GroupBox5: TGroupBox;
57 | GroupLogin: TGroupBox;
58 | GroupLogin1: TGroupBox;
59 | GroupLogin2: TGroupBox;
60 | GroupRegistro: TGroupBox;
61 | GroupTokens: TGroupBox;
62 | GroupTokens1: TGroupBox;
63 | GroupTokens2: TGroupBox;
64 | layoutUserName19: TPanel;
65 | layoutUserName20: TPanel;
66 | layoutUserName21: TPanel;
67 | layoutUserName22: TPanel;
68 | layoutUserName23: TPanel;
69 | layoutUserName24: TPanel;
70 | layoutUserName25: TPanel;
71 | layoutUserName26: TPanel;
72 | layoutUserName27: TPanel;
73 | lblLoginSenha12: TLabel;
74 | lblLoginSenha13: TLabel;
75 | lblLoginSenha14: TLabel;
76 | lblLoginSenha15: TLabel;
77 | lblLoginSenha16: TLabel;
78 | lblLoginUsername4: TLabel;
79 | lblLoginUsername5: TLabel;
80 | lblPerfilEmailVerificado: TLabel;
81 | layoutUserName18: TPanel;
82 | lblLoginSenha11: TLabel;
83 | lblPerfilUltimoAcesso: TLabel;
84 | lblPerfiluID: TLabel;
85 | layoutUserName1: TPanel;
86 | layoutUserName10: TPanel;
87 | layoutUserName11: TPanel;
88 | layoutUserName12: TPanel;
89 | layoutUserName13: TPanel;
90 | layoutUserName14: TPanel;
91 | layoutUserName15: TPanel;
92 | layoutUserName16: TPanel;
93 | layoutUserName17: TPanel;
94 | layoutUserName2: TPanel;
95 | layoutUserName3: TPanel;
96 | layoutUserName4: TPanel;
97 | layoutUserName5: TPanel;
98 | layoutUserName6: TPanel;
99 | layoutUserName7: TPanel;
100 | layoutUserName8: TPanel;
101 | layoutUserName9: TPanel;
102 | lblLoginSenha1: TLabel;
103 | lblLoginSenha10: TLabel;
104 | lblLoginSenha2: TLabel;
105 | lblLoginSenha3: TLabel;
106 | lblLoginSenha4: TLabel;
107 | lblLoginSenha5: TLabel;
108 | lblLoginSenha6: TLabel;
109 | lblLoginSenha7: TLabel;
110 | lblLoginSenha8: TLabel;
111 | lblLoginSenha9: TLabel;
112 | lblLoginUsername1: TLabel;
113 | lblLoginUsername2: TLabel;
114 | lblLoginUsername3: TLabel;
115 | lblPerfilEmail: TLabel;
116 | lblPerfilCriado: TLabel;
117 | lblToken: TLabel;
118 | lblLoginUsername: TLabel;
119 | lblLoginSenha: TLabel;
120 | lblRefreshToken: TLabel;
121 | ListBox1: TListBox;
122 | MemoLog: TMemo;
123 | layoutUserName: TPanel;
124 | selectfile: TOpenDialog;
125 | Panel1: TPanel;
126 | DataGrid: TStringGrid;
127 | TabAuth: TPageControl;
128 | TabServices: TPageControl;
129 | TabFirebaseAuth: TTabSheet;
130 | TabFirebaseStorage: TTabSheet;
131 | TabFirebaseRealtimeDB: TTabSheet;
132 | TabLogin: TTabSheet;
133 | TabRegister: TTabSheet;
134 | TabReset: TTabSheet;
135 | TabPerfil: TTabSheet;
136 | TabVerificarEmail: TTabSheet;
137 | TabApagarConta: TTabSheet;
138 | procedure btApagarContaClick(Sender: TObject);
139 | procedure btAtualizarTokenClick(Sender: TObject);
140 | procedure btEnviarArquivoClick(Sender: TObject);
141 | procedure btExibirPerfilClick(Sender: TObject);
142 | procedure btLoginEntrarClick(Sender: TObject);
143 | procedure btnAddRecordClick(Sender: TObject);
144 | procedure btnDeleteRecordClick(Sender: TObject);
145 | procedure btnReadCollectionClick(Sender: TObject);
146 | procedure btnUpdateRecordClick(Sender: TObject);
147 | procedure btProcurarArquivoClick(Sender: TObject);
148 | procedure btRegistroRegistrarClick(Sender: TObject);
149 | procedure btResetConfirmarClick(Sender: TObject);
150 | procedure btResetResetarClick(Sender: TObject);
151 | procedure btResetVerificarClick(Sender: TObject);
152 | procedure btSalvarPerfilClick(Sender: TObject);
153 | procedure btTrocarSenhaClick(Sender: TObject);
154 | procedure btVerificarEmailEnviaCodeClick(Sender: TObject);
155 | procedure btVerificarEmailVerificaCodeClick(Sender: TObject);
156 | procedure Button1Click(Sender: TObject);
157 | procedure DataGridClick(Sender: TObject);
158 | procedure DataGridSelection(Sender: TObject; aCol, aRow: Integer);
159 | procedure FormCreate(Sender: TObject);
160 | procedure FormShow(Sender: TObject);
161 | private
162 | fToken, fRefreshToken : string;
163 | API_KEY : string;
164 | PROJECT_ID : string;
165 | fID : string;
166 | procedure Add2Log(const texto: string);
167 | procedure PreencheGrid(const Dados: TJSONArray);
168 | public
169 |
170 | end;
171 |
172 | var
173 | FormMain: TFormMain;
174 |
175 | implementation
176 |
177 | {$R *.lfm}
178 |
179 | { TFormMain }
180 |
181 | uses
182 | eFirebase,
183 | eFirebase.Interfaces,
184 | eFirebase.Types,
185 | DotEnv4Delphi;
186 |
187 | {$Region 'Funções Auxiliares'}
188 | function ErrorMessage(const msg: enumAuthErrors): string;
189 | begin
190 | case msg of
191 | NONE: Result := EmptyStr;
192 | EMAIL_EXISTS: Result := 'Já existe uma conta com este e-mail. Informe um outro e-mail para criar uma conta.';
193 | OPERATION_NOT_ALLOWED: Result := 'Operação não permitida! Sentimos muito, mas não é possível prosseguir.';
194 | TOO_MANY_ATTEMPTS_TRY_LATER: Result := 'Sentimos muito, mas você já efetuou muitas tentativas e não poderá prosseguir. Tente novamente mais tarde.';
195 | INVALID_EMAIL: Result := 'O e-mail informado não é válido. Informe um e-mail válido patra prosseguir.';
196 | WEAK_PASSWORD: Result := 'A senha informada é muito fraca. É necessário informar uma senha com pelo menos 6 digitos. Tente novamente!';
197 | EMAIL_NOT_FOUND: Result := 'E-mail informado não encontrado, portanto não foi possível encontrar um usuário no sistema!';
198 | USER_DISABLED: Result := 'Sentimos muito, mas o seu usuário encontra-se desabilitado. Converse com o administrador.';
199 | TOKEN_EXPIRED: Result := 'O token de usuário informado encontra-se expirado. Utilize o RefreshToken para obter um novo Token ou faça o login novamente.';
200 | USER_NOT_FOUND: Result := 'Usuário informado não encontrado. Tente novamente.';
201 | INVALID_REFRESH_TOKEN: Result := 'O RefreshToken informado é inválido. Impossível obter novo token com este RefreshToken.';
202 | INVALID_GRANT_TYPE: Result := 'Permissões inválidas.';
203 | MISSING_REFRESH_TOKEN: Result := 'Não foi possível encontrar o RefreshToken informado.';
204 | EXPIRED_OOB_CODE: Result := 'Código de resgate expirou.';
205 | INVALID_OOB_CODE: Result := 'Código de resgate inválido.';
206 | INVALID_ID_TOKEN: Result := 'Token informado é inválido.';
207 | CREDENTIAL_TOO_OLD_LOGIN_AGAIN: Result := 'Credenciais vencidas. Faça o login novamente.';
208 | INVALID_PASSWORD: Result := 'Senha inválida.';
209 | UNKNOWN: Result := 'Ocorreu um erro desconhecido. Tente novamente.';
210 | end;
211 | end;
212 | procedure TFormMain.Add2Log(const texto: string);
213 | begin
214 | MemoLog.Lines.Add(texto);
215 | end;
216 | function RemoveQuotes(const value: string): string;
217 | begin
218 | Result := StringReplace(value, '"', '', [rfReplaceAll]);
219 | end;
220 | procedure TFormMain.PreencheGrid(const Dados: TJSONArray);
221 | var
222 | Registro : TJSONObject;
223 | i : Integer;
224 | begin
225 | DataGrid.RowCount := 1;
226 |
227 | if Dados.Count > 0 then
228 | begin
229 |
230 | DataGrid.RowCount := Dados.Count + 1;
231 |
232 | for i := 0 to Dados.Count-1 do
233 | begin
234 | Registro := Dados.Items[i] as TJSONObject;
235 | DataGrid.Cells[0, i + 1] := RemoveQuotes(Registro.Find('done').AsJSON);
236 | DataGrid.Cells[1, i + 1] := RemoveQuotes(Registro.Find('id').AsJSON);
237 | DataGrid.Cells[2, i + 1] := RemoveQuotes(Registro.Find('task').AsJSON);
238 | DataGrid.Cells[3, i + 1] := RemoveQuotes(Registro.Find('category').AsJSON);
239 | end;
240 |
241 | end;
242 | end;
243 | {$EndRegion}
244 |
245 | procedure TFormMain.FormCreate(Sender: TObject);
246 | begin
247 | //Setando o título da aplicação concateando com a versão do eFirebase obtida através do comando teFirebase.Version
248 | Self.Caption := 'Simple Demo (LAZARUS) - eFirebase version ' + TeFirebase.Version;
249 |
250 | //Setando aba inicial (a de login)
251 | TabServices.ActivePage := TabFirebaseAuth;
252 |
253 | //Abrir na página de Login
254 | TabAuth.ActivePage := TabLogin;
255 |
256 | //inicializando as variáveis que vão abrigar os tokens necessários para outras ações
257 | fToken := EmptyStr;
258 | fRefreshToken := EmptyStr;
259 |
260 | //lendo variáveis de ambiente necessárias contidas no arquivo .env usando a lib DotEnv4Delphi
261 | API_Key := DotEnv.Env('APIKey'); //A API Key é obtida no Firebase, necessário para maioria das funções do Firebase
262 | Project_ID := DotEnv.Env('ProjectId'); //O ProjectID é necessário para muitas funções do Firebase
263 |
264 | //Variável para guardar o ID do usuário
265 | fID := EmptyStr;
266 | end;
267 |
268 | procedure TFormMain.FormShow(Sender: TObject);
269 | begin
270 | eLoginUsername.SetFocus;
271 | end;
272 |
273 | {$Region 'Funções Firebase Auth'}
274 | procedure TFormMain.btLoginEntrarClick(Sender: TObject);
275 | //Este método é para realizar o login na conta cadastrada de usuário no Firebase
276 | var
277 | //Variavel para guardar o retorno dos métodos do Firebase Auth
278 | Login : ieFirebaseResponseAuth;
279 | begin
280 | //Fazendo verificações para garantir que há os dados de Usuário e senha
281 | if eLoginUsername.Text = EmptyStr then
282 | begin
283 | ShowMessage('É necessário informar um e-mail para efetuar login.');
284 | Exit;
285 | end;
286 |
287 | if eLoginSenha.Text = EmptyStr then
288 | begin
289 | ShowMessage('É necessário informar uma senha para efetuar login.');
290 | Exit;
291 | end;
292 |
293 | try
294 | //Chamada para realizar login do Firebase Auth
295 | Login := TeFirebase.New
296 | .Auth(API_Key)
297 | .SignInWithEmailPassword(eLoginUsername.Text, eLoginSenha.Text);
298 | except
299 | Add2Log('Firebase Auth -> Login falhou!');
300 | end;
301 |
302 | //Verificação se obteve sucesso ao logar
303 | if Login.StatusCode = 200 then
304 | begin
305 | Add2Log('Firebase Auth -> Login efetuado com sucesso!');
306 | //Guardar Tokens para serem usados (extremamente importante, são o que garante que vc está "conectado"
307 | fToken := Login.token;
308 | fRefreshToken := Login.RefreshToken;
309 |
310 | LblToken.Caption := fToken;
311 | LblRefreshToken.Caption := fRefreshToken;
312 | lblToken.WordWrap := True;
313 | lblRefreshToken.WordWrap := True;
314 | end
315 | else
316 | begin
317 | Add2Log('Firebase Auth -> Login falhou: ' + ErrorMessage(Login.Error) + #13 + 'Status Code = ' + Login.StatusCode.ToString);
318 | ShowMessage('Firebase Auth -> Login falhou: ' + ErrorMessage(Login.Error) + #13 + 'Status Code = ' + Login.StatusCode.ToString);
319 | end;
320 | end;
321 |
322 | procedure TFormMain.btnAddRecordClick(Sender: TObject);
323 | var
324 | Registro : TJsonObject;
325 | Bd : ieFirebaseRealtimeResponse;
326 | begin
327 | if fToken = EmptyStr then
328 | begin
329 | ShowMessage('Esta função só funcionará após fazer login ou criar uma conta!');
330 | Exit;
331 | end;
332 |
333 | Registro := TJSONObject.Create;
334 | try
335 | Registro.Add('task', eFieldTask.Text);
336 | Registro.Add('category', eFieldCategory.Text);
337 | Registro.Add('done', false);
338 |
339 | Bd := TeFirebase.New
340 | .RealTimeDB(Project_ID)
341 | .AccessToken(fToken)
342 | .Endpoint(eRealtimeEndpoint.Text)
343 | .Collection(eRealtimeCollection.Text)
344 | .CreateRegister(Registro.AsJSON);
345 |
346 | finally
347 | Registro.Free;
348 | end;
349 |
350 | btnReadCollectionClick(nil);
351 | end;
352 |
353 | procedure TFormMain.btnDeleteRecordClick(Sender: TObject);
354 | var
355 | fDelete : ieFirebaseRealtimeResponse;
356 | begin
357 | if fToken = EmptyStr then
358 | begin
359 | ShowMessage('Esta função só funcionará após fazer login ou criar uma conta!');
360 | Exit;
361 | end;
362 |
363 | if MessageDlg('Deseja realmente apagar o registro selecionado?', TMsgDlgType.mtConfirmation, mbYesNo, 0) = mrNo then
364 | Exit;
365 |
366 | fDelete := TeFirebase.New
367 | .RealTimeDB(Project_ID)
368 | .AccessToken(fToken)
369 | .Endpoint(eRealtimeEndpoint.Text)
370 | .Collection(eRealtimeCollection.Text)
371 | .DeleteRegister(fID);
372 |
373 | if fDelete.StatusCode <> 200 then
374 | begin
375 | ShowMessage('Ocorreu um erro ao tentar excluir o registro!');
376 | Exit;
377 | end;
378 |
379 | ShowMessage('Registro apagado com sucesso!');
380 | btnReadCollectionClick(nil);
381 | end;
382 |
383 | procedure TFormMain.btnReadCollectionClick(Sender: TObject);
384 | var
385 | DataTable : ieFirebaseRealtimeResponse;
386 | JArray : TJSONArray;
387 | begin
388 | if fToken = EmptyStr then
389 | begin
390 | ShowMessage('Esta função só funcionará após fazer login ou criar uma conta!');
391 | Exit;
392 | end;
393 |
394 | DataTable := TeFirebase.New
395 | .RealTimeDB(Project_ID)
396 | .AccessToken(fToken)
397 | .Endpoint(eRealtimeEndPoint.Text)
398 | .Collection(eRealtimeCollection.Text)
399 | .ReadWithoutFilters;
400 |
401 | if DataTable.StatusCode = 200 then
402 | begin
403 | JArray := DataTable.AsJSONArray;
404 | PreencheGrid(JArray);
405 | JArray.Free;
406 | end;
407 | end;
408 |
409 | procedure TFormMain.btnUpdateRecordClick(Sender: TObject);
410 | var
411 | Body : TJSONObject;
412 | fUpdate : ieFirebaseRealtimeResponse;
413 | begin
414 | if fToken = EmptyStr then
415 | begin
416 | ShowMessage('Esta função só funcionará após fazer login ou criar uma conta!');
417 | Exit;
418 | end;
419 |
420 | if fID = EmptyStr then
421 | exit;
422 |
423 | Body := TJSONObject.Create;
424 | Body.Add('task', eFieldTask.Text);
425 | Body.Add('category', eFieldCategory.Text);
426 | Body.Add('done', chFieldDone.Checked);
427 |
428 | fUpdate := TeFirebase.New
429 | .RealTimeDB(Project_ID)
430 | .AccessToken(fToken)
431 | .Endpoint(eRealtimeEndpoint.Text)
432 | .Collection(eRealtimeCollection.Text)
433 | .UpdateRegister(Body.AsJSON, fID);
434 |
435 | Body.Free;
436 |
437 | btnReadCollectionClick(nil);
438 | end;
439 |
440 | procedure TFormMain.btProcurarArquivoClick(Sender: TObject);
441 | begin
442 | if SelectFile.Execute then
443 | begin
444 | eStorageArquivo.Text := SelectFile.FileName;
445 | end;
446 | end;
447 |
448 | procedure TFormMain.btRegistroRegistrarClick(Sender: TObject);
449 | //Método para criar nova conta de usuário no Firebase Auth
450 | var
451 | //Variavel para guardar o retorno dos métodos do Firebase Auth
452 | fRegister : ieFirebaseResponseAuth;
453 | begin
454 | //Fazendo verificações para garantir que há os dados de Usuário e senha
455 | if eRegistroUsername.Text = EmptyStr then
456 | begin
457 | ShowMessage('É necessário informar um e-mail para criar uma conta.');
458 | Exit;
459 | end;
460 |
461 | if eRegistroSenha.Text = EmptyStr then
462 | begin
463 | ShowMessage('É necessário informar uma senha para criar uma conta.');
464 | Exit;
465 | end;
466 |
467 | try
468 | //Chamada para efetuar criação de nova conta de usuário no Firebase Auth
469 | fRegister := TeFirebase.New
470 | .Auth(API_Key)
471 | .SignUpWithEmailPassword(eRegistroUsername.Text, eRegistroSenha.Text);
472 | except
473 | Add2Log('Firebase Auth -> SignUp falhou!');
474 | end;
475 |
476 | //Verificação se obteve sucesso ao criar conta
477 | if fRegister.StatusCode = 200 then
478 | begin
479 | Add2Log('Firebase Auth -> SignUp efetuado com sucesso!');
480 | //Guardar Tokens para serem usados (extremamente importante, são o que garante que vc está "conectado"
481 | fToken := fRegister.token;
482 | fRefreshToken := fRegister.RefreshToken;
483 |
484 | MessageDlg('Conta criada com sucesso', 'Sua conta de usuário no sistema foi criada com sucesso!', TMsgDlgType.mtInformation, [TMsgDlgBtn.mbOK], '');
485 |
486 | LblToken.Caption := fToken;
487 | LblRefreshToken.Caption := fRefreshToken;
488 | lblToken.WordWrap := True;
489 | lblRefreshToken.WordWrap := True;
490 | end
491 | else
492 | begin
493 | Add2Log('Firebase Auth -> SignUp falhou: ' + ErrorMessage(fRegister.Error) + #13 + 'Status Code = ' + fRegister.StatusCode.ToString);
494 | ShowMessage('Firebase Auth -> SignUp falhou: ' + ErrorMessage(fRegister.Error) + #13 + 'Status Code = ' + fRegister.StatusCode.ToString);
495 | end;
496 | end;
497 |
498 | procedure TFormMain.btResetConfirmarClick(Sender: TObject);
499 | //Método para registrar nova senha, para tal precisa ser informado o código enviado para e-mail e a nova senha
500 | var
501 | ResetSenha : ieFirebaseResponseAuth;
502 | begin
503 | //Fazendo verificações para garantir que há os dados de Usuário e senha
504 | if eResetCode.Text = EmptyStr then
505 | begin
506 | ShowMessage('É necessário informar o código de resetamento enviado para o e-mail.');
507 | Exit;
508 | end;
509 |
510 | if eResetNovaSenha.Text = EmptyStr then
511 | begin
512 | ShowMessage('É necessário informar uma nova senha.');
513 | Exit;
514 | end;
515 |
516 | //Chamada para efetuar confirmação da nova senha após resetamento de senha
517 | ResetSenha := TeFirebase.New
518 | .Auth(API_Key)
519 | .ConfirmPasswordReset(eResetCode.Text, eResetNovaSenha.Text);
520 |
521 | if ResetSenha.StatusCode = 200 then
522 | begin
523 | Add2Log('Firebase auth -> Senha resetada com sucesso! Realize o login novamente.');
524 | ShowMessage('Firebase auth -> Senha resetada com sucesso! Realize o login novamente.');
525 | TabAuth.ActivePage := TabLogin;
526 | eLoginSenha.Text := EmptyStr;
527 | eLoginUsername.Text:= EmptyStr;
528 | eLoginUsername.SetFocus;
529 | end
530 | else
531 | Begin
532 | Add2Log('Firebase auth -> Ocorreu um erro ao resetar senha. Erro: ' + ErrorMessage(ResetSenha.Error));
533 | End;
534 | end;
535 |
536 | procedure TFormMain.btResetResetarClick(Sender: TObject);
537 | //Este método é para enviar um e-mail com código para resetar a senha do usuário
538 | var
539 | //Variavel para guardar o retorno dos métodos do Firebase Auth
540 | ResetSenha : ieFirebaseResponseAuth;
541 | begin
542 | //Fazendo verificações para garantir que há o e-mail para enviar o código
543 | if eResetEmail.Text = EmptyStr then
544 | begin
545 | ShowMessage('É necessário informar um e-mail para poder enviar código para resetar a senha.');
546 | Exit;
547 | end;
548 |
549 | //Função principal
550 | ResetSenha := TeFirebase.New
551 | .Auth(API_Key)
552 | .SendPasswordResetEmail(eResetEmail.Text);
553 |
554 | if ResetSenha.StatusCode = 200 then
555 | begin
556 | Add2Log('Firebase auth -> E-mail de reset de senha enviado com sucesso!');
557 | ShowMessage('Firebase auth -> E-mail de reset de senha enviado com sucesso!');
558 | end
559 | else
560 | Begin
561 | Add2Log('Firebase auth -> Email Reset falhou. Erro: ' + ErrorMessage(ResetSenha.Error));
562 | End;
563 | end;
564 |
565 | procedure TFormMain.btResetVerificarClick(Sender: TObject);
566 | //Este método é para verificar se código de resetamento de senha é válido
567 | var
568 | //Variavel para guardar o retorno dos métodos do Firebase Auth
569 | ResetSenha : ieFirebaseResponseAuth;
570 | begin
571 | //Fazendo verificações para garantir que há o e-mail para enviar o código
572 | if eResetCode.Text = EmptyStr then
573 | begin
574 | ShowMessage('É necessário informar o código de resetamento de senha enviado para o e-mail informado.');
575 | Exit;
576 | end;
577 |
578 | //Função principal
579 | ResetSenha := TeFirebase.New
580 | .Auth(API_Key)
581 | .VerifyPasswordResetCode(eResetCode.Text);
582 |
583 | if ResetSenha.StatusCode = 200 then
584 | begin
585 | Add2Log('Firebase auth -> Código verificado com sucesso!');
586 | ShowMessage('Firebase auth -> Código verificado com sucesso!');
587 | end
588 | else
589 | Begin
590 | Add2Log('Firebase auth -> Código inválido. Erro: ' + ErrorMessage(ResetSenha.Error));
591 | End;
592 | end;
593 |
594 | procedure TFormMain.btSalvarPerfilClick(Sender: TObject);
595 | //Este método salva as alterações feitas ao nome de exibição e UTRL Foto do usuário
596 | var
597 | //Variavel para guardar o retorno dos métodos do Firebase Auth
598 | Profile: ieFirebaseResponseAuth;
599 | begin
600 | if fToken = EmptyStr then
601 | begin
602 | ShowMessage('Não é possível acessar o profile sem estar logado. Faça o Login ou crie uma conta.');
603 | Exit;
604 | end;
605 |
606 | try
607 | Profile := TeFirebase.New
608 | .Auth(API_Key)
609 | .ChangeProfile(fToken, ePerfilNome.Text, ePerfilURLFoto.Text);
610 | except
611 | Add2Log('Firebase Auth -> Change Profile falhou!');
612 | end;
613 |
614 | if Profile.StatusCode = 200 then
615 | begin
616 | Add2Log('Firebase Auth -> Change Profile efetuado com sucesso!');
617 |
618 | LblPerfiluID.Caption := Profile.uID;
619 | LblPerfilEmail.Caption := Profile.Email;
620 | ePerfilNome.Text := Profile.DisplayName;
621 | ePerfilURLFoto.Text := Profile.photoUrl;
622 | LblPerfilCriado.Caption := Profile.createdAt;
623 | lblPerfilUltimoAcesso.Caption := Profile.lastLoginAt;
624 |
625 | if Profile.EmailVerified then
626 | lblPerfilEmailVerificado.Caption := 'E-mail verificado'
627 | else
628 | lblPerfilEmailVerificado.Caption := 'E-mail NÃO verificado!';
629 | end
630 | else
631 | begin
632 | Add2Log('Firebase Auth -> Change Profile falhou: ' + ErrorMessage(Profile.Error) + #13 + 'Status Code = ' + Profile.StatusCode.ToString);
633 | ShowMessage('Firebase Auth -> Change Profile falhou: ' + ErrorMessage(Profile.Error) + #13 + 'Status Code = ' + Profile.StatusCode.ToString);
634 | end;
635 | end;
636 |
637 | procedure TFormMain.btTrocarSenhaClick(Sender: TObject);
638 | //Este método é utilizado para trocar a senha da conta
639 | var
640 | //Variavel para guardar o retorno dos métodos do Firebase Auth
641 | TrocaSenha : ieFirebaseResponseAuth;
642 | begin
643 | //Fazendo verificações para garantir que há nova senha
644 | if eTrocarSenha.Text = EmptyStr then
645 | begin
646 | ShowMessage('É necessário informar uma nova senha.');
647 | Exit;
648 | end;
649 |
650 | //Função principal
651 | TrocaSenha := TeFirebase.New
652 | .Auth(API_Key)
653 | .ChangePassword(fToken, eTrocarSenha.Text);
654 |
655 | if TrocaSenha.StatusCode = 200 then
656 | begin
657 | Add2Log('Firebase auth -> Nova Senha salva com sucesso! Realize o login novamente.');
658 | ShowMessage('Firebase auth -> Nova Senha salva com sucesso! Realize o login novamente.');
659 | TabAuth.ActivePage := TabLogin;
660 | eLoginSenha.Text := EmptyStr;
661 | eLoginUsername.Text:= EmptyStr;
662 | eLoginUsername.SetFocus;
663 | end
664 | else
665 | Begin
666 | Add2Log('Firebase auth -> Ocorreu um erro ao trocar senha. Erro: ' + ErrorMessage(TrocaSenha.Error));
667 | End;
668 | end;
669 |
670 | procedure TFormMain.btVerificarEmailEnviaCodeClick(Sender: TObject);
671 | //Este método é para enviar o código de verificação para o e-mail cadastrado do usuário
672 | var
673 | //Variavel para guardar o retorno dos métodos do Firebase Auth
674 | VerifyEmail : ieFirebaseResponseAuth;
675 | begin
676 | if fToken = EmptyStr then
677 | begin
678 | ShowMessage('Não é possível acessar o verificar e-mail sem estar logado. Faça o Login ou crie uma conta.');
679 | TabAuth.ActivePage := TabLogin;
680 | eLoginUsername.SetFocus;
681 | Exit;
682 | end;
683 |
684 | VerifyEmail := TeFirebase.New
685 | .Auth(API_Key)
686 | .SendEmailVerification(fToken);
687 |
688 | if VerifyEmail.StatusCode = 200 then
689 | begin
690 | Add2Log('Firebase auth -> Código de verificação de e-mail enviado com sucesso!');
691 | ShowMessage('Firebase auth -> Código de verificação de e-mail enviado com sucesso!!');
692 | end
693 | else
694 | Begin
695 | Add2Log('Firebase auth -> Envio de código para verificar email falhou. Erro: ' + ErrorMessage(VerifyEmail.Error));
696 | End;
697 | end;
698 |
699 | procedure TFormMain.btVerificarEmailVerificaCodeClick(Sender: TObject);
700 | //Este método é para validar o código de verificação do e-mail
701 | var
702 | //Variavel para guardar o retorno dos métodos do Firebase Auth
703 | VerifyEmail : ieFirebaseResponseAuth;
704 | begin
705 | if eVerificarEmail.Text = EmptyStr then
706 | begin
707 | ShowMessage('Não é possível verificar e-mail sem informar o código recebido pelo e-mail.');
708 | eVerificarEmail.SetFocus;
709 | Exit;
710 | end;
711 |
712 | VerifyEmail := TeFirebase.New
713 | .Auth(API_Key)
714 | .ConfirmEmailVerification(eVerificarEmail.Text);
715 |
716 | if VerifyEmail.StatusCode = 200 then
717 | begin
718 | Add2Log('Firebase auth -> E-mail verificado com sucesso!');
719 | ShowMessage('Firebase auth -> E-mail verificado com sucesso!');
720 | end
721 | else
722 | Begin
723 | Add2Log('Firebase auth -> Verificação de e-mail falhou. Erro: ' + ErrorMessage(VerifyEmail.Error));
724 | End;
725 | end;
726 |
727 | procedure TFormMain.Button1Click(Sender: TObject);
728 | begin
729 |
730 | end;
731 |
732 | procedure TFormMain.DataGridClick(Sender: TObject);
733 | begin
734 |
735 | end;
736 |
737 | procedure TFormMain.DataGridSelection(Sender: TObject; aCol, aRow: Integer);
738 | begin
739 | if DataGrid.RowCount < 1 then
740 | Exit;
741 |
742 | eFieldTask.Text := DataGrid.Cells[2, aRow];
743 | eFieldCategory.Text := DataGrid.Cells[3, aRow];
744 | fID := DataGrid.Cells[1, aRow];
745 | chFieldDone.Checked := DataGrid.Cells[0, aRow].ToBoolean;
746 | end;
747 |
748 |
749 | procedure TFormMain.btAtualizarTokenClick(Sender: TObject);
750 | //Este método é para pegar um novo token válido usando o Refresh Token (não precisa usar o Usuário e Senha novamente)
751 | var
752 | //Variavel para guardar o retorno dos métodos do Firebase Auth
753 | RefreshUser : ieFirebaseResponseAuth;
754 | begin
755 | //Verifica se há RefreshToken, se não tiver, sai, pois função não funcionaria sem RefreshToken
756 | if fRefreshToken = EmptyStr then
757 | Exit;
758 |
759 | //Chamada para executar / atualizar o RefreshToken
760 | RefreshUser := TeFirebase.New
761 | .Auth(API_Key)
762 | .ExchangeRefreshToken4idToken(fRefreshToken);
763 |
764 | //Obtendo o resultado
765 | if RefreshUser.StatusCode = 200 then
766 | begin
767 | fToken := RefreshUser.token;
768 | fRefreshToken := RefreshUser.RefreshToken;
769 |
770 | LblToken.Caption := fToken;
771 | LblRefreshToken.Caption := fRefreshToken;
772 | lblToken.WordWrap := True;
773 | lblRefreshToken.WordWrap := True;
774 | end;
775 | end;
776 |
777 | procedure TFormMain.btEnviarArquivoClick(Sender: TObject);
778 | //Este método é para enviar arquivos para o Firebase Storage
779 | var
780 | Storage : ieFirebaseStorageResponse;
781 | begin
782 | if fToken = EmptyStr then
783 | ShowMessage('Não é possível enviar arquivo sem estar logado. Realize o login e tente novamente.');
784 |
785 | if eStorageArquivo.Text = EmptyStr then
786 | Exit;
787 |
788 | Storage := TeFirebase.New
789 | .Storage(Project_ID)
790 | .Folder(eStoragePasta.Text)
791 | .FileName(eStorageArquivo.Text)
792 | .Send(fToken);
793 |
794 | if Storage.StatusCode = 200 then
795 | begin
796 | Add2Log('Firebase Storage -> Arquivo enviado com sucesso!');
797 | ShowMessage('Firebase Storage -> Arquivo enviado com sucesso!');
798 | ListBox1.Items.Add(Storage.Link);
799 | end
800 | else
801 | begin
802 | Add2Log('Firebase Storage -> Falha ao tentar enviar arquivo.');
803 | end;
804 | end;
805 |
806 | procedure TFormMain.btApagarContaClick(Sender: TObject);
807 | //Este método apaga conta do usuário
808 | var
809 | //Variavel para guardar o retorno dos métodos do Firebase Auth
810 | Profile: ieFirebaseResponseAuth;
811 | begin
812 | if fToken = EmptyStr then
813 | begin
814 | ShowMessage('Não é possível apagar conta sem estar logado. Faça o Login ou crie uma conta.');
815 | Exit;
816 | end;
817 |
818 | if MessageDlg('Deseja realmente apagar sua conta?', TMsgDlgType.mtConfirmation, mbYesNo, 0) = mrNo then
819 | Exit;
820 |
821 | try
822 | Profile := TeFirebase.New
823 | .Auth(API_Key)
824 | .DeleteAccount(fToken);
825 | except
826 | Add2Log('Firebase Auth -> Apagar Conta falhou!');
827 | end;
828 |
829 | if Profile.StatusCode = 200 then
830 | begin
831 | Add2Log('Firebase Auth -> Apagar Conta efetuado com sucesso!');
832 |
833 | ShowMessage('Conta excluída com sucesso.');
834 | end
835 | else
836 | begin
837 | Add2Log('Firebase Auth -> Apagar Conta falhou: ' + ErrorMessage(Profile.Error) + #13 + 'Status Code = ' + Profile.StatusCode.ToString);
838 | ShowMessage('Firebase Auth -> Apagar Conta falhou: ' + ErrorMessage(Profile.Error) + #13 + 'Status Code = ' + Profile.StatusCode.ToString);
839 | end;
840 | end;
841 |
842 | procedure TFormMain.btExibirPerfilClick(Sender: TObject);
843 | //Este método irá exibir as informações da conta do usuário logado
844 | var
845 | //Variavel para guardar o retorno dos métodos do Firebase Auth
846 | Profile : ieFirebaseResponseAuth;
847 | begin
848 | if fToken = EmptyStr then
849 | begin
850 | ShowMessage('Não é possível acessar o profile sem estar logado. Faça o Login ou crie uma conta.');
851 | TabAuth.ActivePage := TabLogin;
852 | eLoginUsername.SetFocus;
853 | Exit;
854 | end;
855 |
856 | try
857 | Profile := TeFirebase.New
858 | .Auth(API_Key)
859 | .GetProfile(fToken);
860 | except
861 | Add2Log('Firebase Auth -> Get Profile falhou!');
862 | end;
863 |
864 | if Profile.StatusCode = 200 then
865 | begin
866 | Add2Log('Firebase Auth -> Get Profile efetuado com sucesso!');
867 |
868 | LblPerfiluID.Caption := Profile.uID;
869 | LblPerfilEmail.Caption := Profile.Email;
870 | ePerfilNome.Text := Profile.DisplayName;
871 | ePerfilURLFoto.Text := Profile.photoUrl;
872 | LblPerfilCriado.Caption := Profile.createdAt;
873 | lblPerfilUltimoAcesso.Caption := Profile.lastLoginAt;
874 |
875 | if Profile.EmailVerified then
876 | lblPerfilEmailVerificado.Caption := 'E-mail verificado'
877 | else
878 | lblPerfilEmailVerificado.Caption := 'E-mail NÃO verificado!';
879 | end
880 | else
881 | begin
882 | Add2Log('Firebase Auth -> Get Profile falhou: ' + ErrorMessage(Profile.Error) + #13 + 'Status Code = ' + Profile.StatusCode.ToString);
883 | ShowMessage('Firebase Auth -> Get Profile falhou: ' + ErrorMessage(Profile.Error) + #13 + 'Status Code = ' + Profile.StatusCode.ToString);
884 | end;
885 | end;
886 |
887 | {$EndRegion}
888 |
889 | end.
890 |
891 |
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/backup/unitmain.pas:
--------------------------------------------------------------------------------
1 | unit unitMain;
2 |
3 | {$mode objfpc}{$H+}
4 |
5 | interface
6 |
7 | uses
8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, StdCtrls,
9 | ExtCtrls, Grids, IpHtml, Types, fpjson;
10 |
11 | type
12 |
13 | { TFormMain }
14 |
15 | TFormMain = class(TForm)
16 | btEnviarArquivo: TButton;
17 | btnReadCollection: TButton;
18 | btnAddRecord: TButton;
19 | btnUpdateRecord: TButton;
20 | btnDeleteRecord: TButton;
21 | btProcurarArquivo: TButton;
22 | btTrocarSenha: TButton;
23 | btLoginEntrar: TButton;
24 | btAtualizarToken: TButton;
25 | btResetConfirmar: TButton;
26 | btResetResetar: TButton;
27 | btResetVerificar: TButton;
28 | btRegistroRegistrar: TButton;
29 | btExibirPerfil: TButton;
30 | btSalvarPerfil: TButton;
31 | btVerificarEmailEnviaCode: TButton;
32 | btVerificarEmailVerificaCode: TButton;
33 | btApagarConta: TButton;
34 | chFieldDone: TCheckBox;
35 | eStorageArquivo: TEdit;
36 | eRealtimeCollection: TEdit;
37 | eFieldTask: TEdit;
38 | eFieldCategory: TEdit;
39 | eStoragePasta: TEdit;
40 | eResetCode: TEdit;
41 | eResetNovaSenha: TEdit;
42 | ePerfilNome: TEdit;
43 | ePerfilURLFoto: TEdit;
44 | eRealtimeEndpoint: TEdit;
45 | eTrocarSenha: TEdit;
46 | eResetEmail: TEdit;
47 | eRegistroSenha: TEdit;
48 | eLoginUsername: TEdit;
49 | eLoginSenha: TEdit;
50 | eRegistroUsername: TEdit;
51 | eVerificarEmail: TEdit;
52 | GroupBox1: TGroupBox;
53 | GroupBox2: TGroupBox;
54 | GroupBox3: TGroupBox;
55 | GroupBox4: TGroupBox;
56 | GroupBox5: TGroupBox;
57 | GroupLogin: TGroupBox;
58 | GroupLogin1: TGroupBox;
59 | GroupLogin2: TGroupBox;
60 | GroupRegistro: TGroupBox;
61 | GroupTokens: TGroupBox;
62 | GroupTokens1: TGroupBox;
63 | GroupTokens2: TGroupBox;
64 | layoutUserName19: TPanel;
65 | layoutUserName20: TPanel;
66 | layoutUserName21: TPanel;
67 | layoutUserName22: TPanel;
68 | layoutUserName23: TPanel;
69 | layoutUserName24: TPanel;
70 | layoutUserName25: TPanel;
71 | layoutUserName26: TPanel;
72 | layoutUserName27: TPanel;
73 | lblLoginSenha12: TLabel;
74 | lblLoginSenha13: TLabel;
75 | lblLoginSenha14: TLabel;
76 | lblLoginSenha15: TLabel;
77 | lblLoginSenha16: TLabel;
78 | lblLoginUsername4: TLabel;
79 | lblLoginUsername5: TLabel;
80 | lblPerfilEmailVerificado: TLabel;
81 | layoutUserName18: TPanel;
82 | lblLoginSenha11: TLabel;
83 | lblPerfilUltimoAcesso: TLabel;
84 | lblPerfiluID: TLabel;
85 | layoutUserName1: TPanel;
86 | layoutUserName10: TPanel;
87 | layoutUserName11: TPanel;
88 | layoutUserName12: TPanel;
89 | layoutUserName13: TPanel;
90 | layoutUserName14: TPanel;
91 | layoutUserName15: TPanel;
92 | layoutUserName16: TPanel;
93 | layoutUserName17: TPanel;
94 | layoutUserName2: TPanel;
95 | layoutUserName3: TPanel;
96 | layoutUserName4: TPanel;
97 | layoutUserName5: TPanel;
98 | layoutUserName6: TPanel;
99 | layoutUserName7: TPanel;
100 | layoutUserName8: TPanel;
101 | layoutUserName9: TPanel;
102 | lblLoginSenha1: TLabel;
103 | lblLoginSenha10: TLabel;
104 | lblLoginSenha2: TLabel;
105 | lblLoginSenha3: TLabel;
106 | lblLoginSenha4: TLabel;
107 | lblLoginSenha5: TLabel;
108 | lblLoginSenha6: TLabel;
109 | lblLoginSenha7: TLabel;
110 | lblLoginSenha8: TLabel;
111 | lblLoginSenha9: TLabel;
112 | lblLoginUsername1: TLabel;
113 | lblLoginUsername2: TLabel;
114 | lblLoginUsername3: TLabel;
115 | lblPerfilEmail: TLabel;
116 | lblPerfilCriado: TLabel;
117 | lblToken: TLabel;
118 | lblLoginUsername: TLabel;
119 | lblLoginSenha: TLabel;
120 | lblRefreshToken: TLabel;
121 | ListBox1: TListBox;
122 | MemoLog: TMemo;
123 | layoutUserName: TPanel;
124 | selectfile: TOpenDialog;
125 | Panel1: TPanel;
126 | DataGrid: TStringGrid;
127 | TabAuth: TPageControl;
128 | TabServices: TPageControl;
129 | TabFirebaseAuth: TTabSheet;
130 | TabFirebaseStorage: TTabSheet;
131 | TabFirebaseRealtimeDB: TTabSheet;
132 | TabLogin: TTabSheet;
133 | TabRegister: TTabSheet;
134 | TabReset: TTabSheet;
135 | TabPerfil: TTabSheet;
136 | TabVerificarEmail: TTabSheet;
137 | TabApagarConta: TTabSheet;
138 | procedure btApagarContaClick(Sender: TObject);
139 | procedure btAtualizarTokenClick(Sender: TObject);
140 | procedure btEnviarArquivoClick(Sender: TObject);
141 | procedure btExibirPerfilClick(Sender: TObject);
142 | procedure btLoginEntrarClick(Sender: TObject);
143 | procedure btnAddRecordClick(Sender: TObject);
144 | procedure btnDeleteRecordClick(Sender: TObject);
145 | procedure btnReadCollectionClick(Sender: TObject);
146 | procedure btnUpdateRecordClick(Sender: TObject);
147 | procedure btProcurarArquivoClick(Sender: TObject);
148 | procedure btRegistroRegistrarClick(Sender: TObject);
149 | procedure btResetConfirmarClick(Sender: TObject);
150 | procedure btResetResetarClick(Sender: TObject);
151 | procedure btResetVerificarClick(Sender: TObject);
152 | procedure btSalvarPerfilClick(Sender: TObject);
153 | procedure btTrocarSenhaClick(Sender: TObject);
154 | procedure btVerificarEmailEnviaCodeClick(Sender: TObject);
155 | procedure btVerificarEmailVerificaCodeClick(Sender: TObject);
156 | procedure Button1Click(Sender: TObject);
157 | procedure DataGridClick(Sender: TObject);
158 | procedure DataGridSelection(Sender: TObject; aCol, aRow: Integer);
159 | procedure FormCreate(Sender: TObject);
160 | procedure FormShow(Sender: TObject);
161 | private
162 | fToken, fRefreshToken : string;
163 | API_KEY : string;
164 | PROJECT_ID : string;
165 | fID : string;
166 | procedure Add2Log(const texto: string);
167 | procedure PreencheGrid(const Dados: TJSONArray);
168 | public
169 |
170 | end;
171 |
172 | var
173 | FormMain: TFormMain;
174 |
175 | implementation
176 |
177 | {$R *.lfm}
178 |
179 | { TFormMain }
180 |
181 | uses
182 | eFirebase,
183 | eFirebase.Interfaces,
184 | eFirebase.Types,
185 | DotEnv4Delphi;
186 |
187 | {$Region 'Funções Auxiliares'}
188 | function ErrorMessage(const msg: enumAuthErrors): string;
189 | begin
190 | case msg of
191 | NONE: Result := EmptyStr;
192 | EMAIL_EXISTS: Result := 'Já existe uma conta com este e-mail. Informe um outro e-mail para criar uma conta.';
193 | OPERATION_NOT_ALLOWED: Result := 'Operação não permitida! Sentimos muito, mas não é possível prosseguir.';
194 | TOO_MANY_ATTEMPTS_TRY_LATER: Result := 'Sentimos muito, mas você já efetuou muitas tentativas e não poderá prosseguir. Tente novamente mais tarde.';
195 | INVALID_EMAIL: Result := 'O e-mail informado não é válido. Informe um e-mail válido patra prosseguir.';
196 | WEAK_PASSWORD: Result := 'A senha informada é muito fraca. É necessário informar uma senha com pelo menos 6 digitos. Tente novamente!';
197 | EMAIL_NOT_FOUND: Result := 'E-mail informado não encontrado, portanto não foi possível encontrar um usuário no sistema!';
198 | USER_DISABLED: Result := 'Sentimos muito, mas o seu usuário encontra-se desabilitado. Converse com o administrador.';
199 | TOKEN_EXPIRED: Result := 'O token de usuário informado encontra-se expirado. Utilize o RefreshToken para obter um novo Token ou faça o login novamente.';
200 | USER_NOT_FOUND: Result := 'Usuário informado não encontrado. Tente novamente.';
201 | INVALID_REFRESH_TOKEN: Result := 'O RefreshToken informado é inválido. Impossível obter novo token com este RefreshToken.';
202 | INVALID_GRANT_TYPE: Result := 'Permissões inválidas.';
203 | MISSING_REFRESH_TOKEN: Result := 'Não foi possível encontrar o RefreshToken informado.';
204 | EXPIRED_OOB_CODE: Result := 'Código de resgate expirou.';
205 | INVALID_OOB_CODE: Result := 'Código de resgate inválido.';
206 | INVALID_ID_TOKEN: Result := 'Token informado é inválido.';
207 | CREDENTIAL_TOO_OLD_LOGIN_AGAIN: Result := 'Credenciais vencidas. Faça o login novamente.';
208 | INVALID_PASSWORD: Result := 'Senha inválida.';
209 | UNKNOWN: Result := 'Ocorreu um erro desconhecido. Tente novamente.';
210 | end;
211 | end;
212 | procedure TFormMain.Add2Log(const texto: string);
213 | begin
214 | MemoLog.Lines.Add(texto);
215 | end;
216 | function RemoveQuotes(const value: string): string;
217 | begin
218 | Result := StringReplace(value, '"', '', [rfReplaceAll]);
219 | end;
220 | procedure TFormMain.PreencheGrid(const Dados: TJSONArray);
221 | var
222 | Registro : TJSONObject;
223 | i : Integer;
224 | begin
225 | DataGrid.RowCount := 1;
226 |
227 | if Dados.Count > 0 then
228 | begin
229 |
230 | DataGrid.RowCount := Dados.Count + 1;
231 |
232 | for i := 0 to Dados.Count-1 do
233 | begin
234 | Registro := Dados.Items[i] as TJSONObject;
235 | DataGrid.Cells[0, i + 1] := RemoveQuotes(Registro.Find('done').AsJSON);
236 | DataGrid.Cells[1, i + 1] := RemoveQuotes(Registro.Find('id').AsJSON);
237 | DataGrid.Cells[2, i + 1] := RemoveQuotes(Registro.Find('task').AsJSON);
238 | DataGrid.Cells[3, i + 1] := RemoveQuotes(Registro.Find('category').AsJSON);
239 | end;
240 |
241 | end;
242 | end;
243 | {$EndRegion}
244 |
245 | procedure TFormMain.FormCreate(Sender: TObject);
246 | begin
247 | //Setando o título da aplicação concateando com a versão do eFirebase obtida através do comando teFirebase.Version
248 | Self.Caption := 'Simple Demo (LAZARUS) - eFirebase version ' + TeFirebase.Version;
249 |
250 | //Setando aba inicial (a de login)
251 | TabServices.ActivePage := TabFirebaseAuth;
252 |
253 | //Abrir na página de Login
254 | TabAuth.ActivePage := TabLogin;
255 |
256 | //inicializando as variáveis que vão abrigar os tokens necessários para outras ações
257 | fToken := EmptyStr;
258 | fRefreshToken := EmptyStr;
259 |
260 | //lendo variáveis de ambiente necessárias contidas no arquivo .env usando a lib DotEnv4Delphi
261 | API_Key := DotEnv.Env('APIKey'); //A API Key é obtida no Firebase, necessário para maioria das funções do Firebase
262 | Project_ID := DotEnv.Env('ProjectId'); //O ProjectID é necessário para muitas funções do Firebase
263 |
264 | //Variável para guardar o ID do usuário
265 | fID := EmptyStr;
266 | end;
267 |
268 | procedure TFormMain.FormShow(Sender: TObject);
269 | begin
270 | eLoginUsername.SetFocus;
271 | end;
272 |
273 | {$Region 'Funções Firebase Auth'}
274 | procedure TFormMain.btLoginEntrarClick(Sender: TObject);
275 | //Este método é para realizar o login na conta cadastrada de usuário no Firebase
276 | var
277 | //Variavel para guardar o retorno dos métodos do Firebase Auth
278 | Login : ieFirebaseResponseAuth;
279 | begin
280 | //Fazendo verificações para garantir que há os dados de Usuário e senha
281 | if eLoginUsername.Text = EmptyStr then
282 | begin
283 | ShowMessage('É necessário informar um e-mail para efetuar login.');
284 | Exit;
285 | end;
286 |
287 | if eLoginSenha.Text = EmptyStr then
288 | begin
289 | ShowMessage('É necessário informar uma senha para efetuar login.');
290 | Exit;
291 | end;
292 |
293 | try
294 | //Chamada para realizar login do Firebase Auth
295 | Login := TeFirebase.New
296 | .Auth(API_Key)
297 | .SignInWithEmailPassword(eLoginUsername.Text, eLoginSenha.Text);
298 | except
299 | Add2Log('Firebase Auth -> Login falhou!');
300 | end;
301 |
302 | //Verificação se obteve sucesso ao logar
303 | if Login.StatusCode = 200 then
304 | begin
305 | Add2Log('Firebase Auth -> Login efetuado com sucesso!');
306 | //Guardar Tokens para serem usados (extremamente importante, são o que garante que vc está "conectado"
307 | fToken := Login.token;
308 | fRefreshToken := Login.RefreshToken;
309 | Add2Log(fRefreshToken);
310 |
311 | LblToken.Caption := fToken;
312 | LblRefreshToken.Caption := fRefreshToken;
313 | lblToken.WordWrap := True;
314 | lblRefreshToken.WordWrap := True;
315 | end
316 | else
317 | begin
318 | Add2Log('Firebase Auth -> Login falhou: ' + ErrorMessage(Login.Error) + #13 + 'Status Code = ' + Login.StatusCode.ToString);
319 | ShowMessage('Firebase Auth -> Login falhou: ' + ErrorMessage(Login.Error) + #13 + 'Status Code = ' + Login.StatusCode.ToString);
320 | end;
321 | end;
322 |
323 | procedure TFormMain.btnAddRecordClick(Sender: TObject);
324 | var
325 | Registro : TJsonObject;
326 | Bd : ieFirebaseRealtimeResponse;
327 | begin
328 | if fToken = EmptyStr then
329 | begin
330 | ShowMessage('Esta função só funcionará após fazer login ou criar uma conta!');
331 | Exit;
332 | end;
333 |
334 | Registro := TJSONObject.Create;
335 | try
336 | Registro.Add('task', eFieldTask.Text);
337 | Registro.Add('category', eFieldCategory.Text);
338 | Registro.Add('done', false);
339 |
340 | Bd := TeFirebase.New
341 | .RealTimeDB(Project_ID)
342 | .AccessToken(fToken)
343 | .Endpoint(eRealtimeEndpoint.Text)
344 | .Collection(eRealtimeCollection.Text)
345 | .CreateRegister(Registro.AsJSON);
346 |
347 | finally
348 | Registro.Free;
349 | end;
350 |
351 | btnReadCollectionClick(nil);
352 | end;
353 |
354 | procedure TFormMain.btnDeleteRecordClick(Sender: TObject);
355 | var
356 | fDelete : ieFirebaseRealtimeResponse;
357 | begin
358 | if fToken = EmptyStr then
359 | begin
360 | ShowMessage('Esta função só funcionará após fazer login ou criar uma conta!');
361 | Exit;
362 | end;
363 |
364 | if MessageDlg('Deseja realmente apagar o registro selecionado?', TMsgDlgType.mtConfirmation, mbYesNo, 0) = mrNo then
365 | Exit;
366 |
367 | fDelete := TeFirebase.New
368 | .RealTimeDB(Project_ID)
369 | .AccessToken(fToken)
370 | .Endpoint(eRealtimeEndpoint.Text)
371 | .Collection(eRealtimeCollection.Text)
372 | .DeleteRegister(fID);
373 |
374 | if fDelete.StatusCode <> 200 then
375 | begin
376 | ShowMessage('Ocorreu um erro ao tentar excluir o registro!');
377 | Exit;
378 | end;
379 |
380 | ShowMessage('Registro apagado com sucesso!');
381 | btnReadCollectionClick(nil);
382 | end;
383 |
384 | procedure TFormMain.btnReadCollectionClick(Sender: TObject);
385 | var
386 | DataTable : ieFirebaseRealtimeResponse;
387 | JArray : TJSONArray;
388 | begin
389 | if fToken = EmptyStr then
390 | begin
391 | ShowMessage('Esta função só funcionará após fazer login ou criar uma conta!');
392 | Exit;
393 | end;
394 |
395 | DataTable := TeFirebase.New
396 | .RealTimeDB(Project_ID)
397 | .AccessToken(fToken)
398 | .Endpoint(eRealtimeEndPoint.Text)
399 | .Collection(eRealtimeCollection.Text)
400 | .ReadWithoutFilters;
401 |
402 | if DataTable.StatusCode = 200 then
403 | begin
404 | JArray := DataTable.AsJSONArray;
405 | PreencheGrid(JArray);
406 | JArray.Free;
407 | end;
408 | end;
409 |
410 | procedure TFormMain.btnUpdateRecordClick(Sender: TObject);
411 | var
412 | Body : TJSONObject;
413 | fUpdate : ieFirebaseRealtimeResponse;
414 | begin
415 | if fToken = EmptyStr then
416 | begin
417 | ShowMessage('Esta função só funcionará após fazer login ou criar uma conta!');
418 | Exit;
419 | end;
420 |
421 | if fID = EmptyStr then
422 | exit;
423 |
424 | Body := TJSONObject.Create;
425 | Body.Add('task', eFieldTask.Text);
426 | Body.Add('category', eFieldCategory.Text);
427 | Body.Add('done', chFieldDone.Checked);
428 |
429 | fUpdate := TeFirebase.New
430 | .RealTimeDB(Project_ID)
431 | .AccessToken(fToken)
432 | .Endpoint(eRealtimeEndpoint.Text)
433 | .Collection(eRealtimeCollection.Text)
434 | .UpdateRegister(Body.AsJSON, fID);
435 |
436 | Body.Free;
437 |
438 | btnReadCollectionClick(nil);
439 | end;
440 |
441 | procedure TFormMain.btProcurarArquivoClick(Sender: TObject);
442 | begin
443 | if SelectFile.Execute then
444 | begin
445 | eStorageArquivo.Text := SelectFile.FileName;
446 | end;
447 | end;
448 |
449 | procedure TFormMain.btRegistroRegistrarClick(Sender: TObject);
450 | //Método para criar nova conta de usuário no Firebase Auth
451 | var
452 | //Variavel para guardar o retorno dos métodos do Firebase Auth
453 | fRegister : ieFirebaseResponseAuth;
454 | begin
455 | //Fazendo verificações para garantir que há os dados de Usuário e senha
456 | if eRegistroUsername.Text = EmptyStr then
457 | begin
458 | ShowMessage('É necessário informar um e-mail para criar uma conta.');
459 | Exit;
460 | end;
461 |
462 | if eRegistroSenha.Text = EmptyStr then
463 | begin
464 | ShowMessage('É necessário informar uma senha para criar uma conta.');
465 | Exit;
466 | end;
467 |
468 | try
469 | //Chamada para efetuar criação de nova conta de usuário no Firebase Auth
470 | fRegister := TeFirebase.New
471 | .Auth(API_Key)
472 | .SignUpWithEmailPassword(eRegistroUsername.Text, eRegistroSenha.Text);
473 | except
474 | Add2Log('Firebase Auth -> SignUp falhou!');
475 | end;
476 |
477 | //Verificação se obteve sucesso ao criar conta
478 | if fRegister.StatusCode = 200 then
479 | begin
480 | Add2Log('Firebase Auth -> SignUp efetuado com sucesso!');
481 | //Guardar Tokens para serem usados (extremamente importante, são o que garante que vc está "conectado"
482 | fToken := fRegister.token;
483 | fRefreshToken := fRegister.RefreshToken;
484 |
485 | MessageDlg('Conta criada com sucesso', 'Sua conta de usuário no sistema foi criada com sucesso!', TMsgDlgType.mtInformation, [TMsgDlgBtn.mbOK], '');
486 |
487 | LblToken.Caption := fToken;
488 | LblRefreshToken.Caption := fRefreshToken;
489 | lblToken.WordWrap := True;
490 | lblRefreshToken.WordWrap := True;
491 | end
492 | else
493 | begin
494 | Add2Log('Firebase Auth -> SignUp falhou: ' + ErrorMessage(fRegister.Error) + #13 + 'Status Code = ' + fRegister.StatusCode.ToString);
495 | ShowMessage('Firebase Auth -> SignUp falhou: ' + ErrorMessage(fRegister.Error) + #13 + 'Status Code = ' + fRegister.StatusCode.ToString);
496 | end;
497 | end;
498 |
499 | procedure TFormMain.btResetConfirmarClick(Sender: TObject);
500 | //Método para registrar nova senha, para tal precisa ser informado o código enviado para e-mail e a nova senha
501 | var
502 | ResetSenha : ieFirebaseResponseAuth;
503 | begin
504 | //Fazendo verificações para garantir que há os dados de Usuário e senha
505 | if eResetCode.Text = EmptyStr then
506 | begin
507 | ShowMessage('É necessário informar o código de resetamento enviado para o e-mail.');
508 | Exit;
509 | end;
510 |
511 | if eResetNovaSenha.Text = EmptyStr then
512 | begin
513 | ShowMessage('É necessário informar uma nova senha.');
514 | Exit;
515 | end;
516 |
517 | //Chamada para efetuar confirmação da nova senha após resetamento de senha
518 | ResetSenha := TeFirebase.New
519 | .Auth(API_Key)
520 | .ConfirmPasswordReset(eResetCode.Text, eResetNovaSenha.Text);
521 |
522 | if ResetSenha.StatusCode = 200 then
523 | begin
524 | Add2Log('Firebase auth -> Senha resetada com sucesso! Realize o login novamente.');
525 | ShowMessage('Firebase auth -> Senha resetada com sucesso! Realize o login novamente.');
526 | TabAuth.ActivePage := TabLogin;
527 | eLoginSenha.Text := EmptyStr;
528 | eLoginUsername.Text:= EmptyStr;
529 | eLoginUsername.SetFocus;
530 | end
531 | else
532 | Begin
533 | Add2Log('Firebase auth -> Ocorreu um erro ao resetar senha. Erro: ' + ErrorMessage(ResetSenha.Error));
534 | End;
535 | end;
536 |
537 | procedure TFormMain.btResetResetarClick(Sender: TObject);
538 | //Este método é para enviar um e-mail com código para resetar a senha do usuário
539 | var
540 | //Variavel para guardar o retorno dos métodos do Firebase Auth
541 | ResetSenha : ieFirebaseResponseAuth;
542 | begin
543 | //Fazendo verificações para garantir que há o e-mail para enviar o código
544 | if eResetEmail.Text = EmptyStr then
545 | begin
546 | ShowMessage('É necessário informar um e-mail para poder enviar código para resetar a senha.');
547 | Exit;
548 | end;
549 |
550 | //Função principal
551 | ResetSenha := TeFirebase.New
552 | .Auth(API_Key)
553 | .SendPasswordResetEmail(eResetEmail.Text);
554 |
555 | if ResetSenha.StatusCode = 200 then
556 | begin
557 | Add2Log('Firebase auth -> E-mail de reset de senha enviado com sucesso!');
558 | ShowMessage('Firebase auth -> E-mail de reset de senha enviado com sucesso!');
559 | end
560 | else
561 | Begin
562 | Add2Log('Firebase auth -> Email Reset falhou. Erro: ' + ErrorMessage(ResetSenha.Error));
563 | End;
564 | end;
565 |
566 | procedure TFormMain.btResetVerificarClick(Sender: TObject);
567 | //Este método é para verificar se código de resetamento de senha é válido
568 | var
569 | //Variavel para guardar o retorno dos métodos do Firebase Auth
570 | ResetSenha : ieFirebaseResponseAuth;
571 | begin
572 | //Fazendo verificações para garantir que há o e-mail para enviar o código
573 | if eResetCode.Text = EmptyStr then
574 | begin
575 | ShowMessage('É necessário informar o código de resetamento de senha enviado para o e-mail informado.');
576 | Exit;
577 | end;
578 |
579 | //Função principal
580 | ResetSenha := TeFirebase.New
581 | .Auth(API_Key)
582 | .VerifyPasswordResetCode(eResetCode.Text);
583 |
584 | if ResetSenha.StatusCode = 200 then
585 | begin
586 | Add2Log('Firebase auth -> Código verificado com sucesso!');
587 | ShowMessage('Firebase auth -> Código verificado com sucesso!');
588 | end
589 | else
590 | Begin
591 | Add2Log('Firebase auth -> Código inválido. Erro: ' + ErrorMessage(ResetSenha.Error));
592 | End;
593 | end;
594 |
595 | procedure TFormMain.btSalvarPerfilClick(Sender: TObject);
596 | //Este método salva as alterações feitas ao nome de exibição e UTRL Foto do usuário
597 | var
598 | //Variavel para guardar o retorno dos métodos do Firebase Auth
599 | Profile: ieFirebaseResponseAuth;
600 | begin
601 | if fToken = EmptyStr then
602 | begin
603 | ShowMessage('Não é possível acessar o profile sem estar logado. Faça o Login ou crie uma conta.');
604 | Exit;
605 | end;
606 |
607 | try
608 | Profile := TeFirebase.New
609 | .Auth(API_Key)
610 | .ChangeProfile(fToken, ePerfilNome.Text, ePerfilURLFoto.Text);
611 | except
612 | Add2Log('Firebase Auth -> Change Profile falhou!');
613 | end;
614 |
615 | if Profile.StatusCode = 200 then
616 | begin
617 | Add2Log('Firebase Auth -> Change Profile efetuado com sucesso!');
618 |
619 | LblPerfiluID.Caption := Profile.uID;
620 | LblPerfilEmail.Caption := Profile.Email;
621 | ePerfilNome.Text := Profile.DisplayName;
622 | ePerfilURLFoto.Text := Profile.photoUrl;
623 | LblPerfilCriado.Caption := Profile.createdAt;
624 | lblPerfilUltimoAcesso.Caption := Profile.lastLoginAt;
625 |
626 | if Profile.EmailVerified then
627 | lblPerfilEmailVerificado.Caption := 'E-mail verificado'
628 | else
629 | lblPerfilEmailVerificado.Caption := 'E-mail NÃO verificado!';
630 | end
631 | else
632 | begin
633 | Add2Log('Firebase Auth -> Change Profile falhou: ' + ErrorMessage(Profile.Error) + #13 + 'Status Code = ' + Profile.StatusCode.ToString);
634 | ShowMessage('Firebase Auth -> Change Profile falhou: ' + ErrorMessage(Profile.Error) + #13 + 'Status Code = ' + Profile.StatusCode.ToString);
635 | end;
636 | end;
637 |
638 | procedure TFormMain.btTrocarSenhaClick(Sender: TObject);
639 | //Este método é utilizado para trocar a senha da conta
640 | var
641 | //Variavel para guardar o retorno dos métodos do Firebase Auth
642 | TrocaSenha : ieFirebaseResponseAuth;
643 | begin
644 | //Fazendo verificações para garantir que há nova senha
645 | if eTrocarSenha.Text = EmptyStr then
646 | begin
647 | ShowMessage('É necessário informar uma nova senha.');
648 | Exit;
649 | end;
650 |
651 | //Função principal
652 | TrocaSenha := TeFirebase.New
653 | .Auth(API_Key)
654 | .ChangePassword(fToken, eTrocarSenha.Text);
655 |
656 | if TrocaSenha.StatusCode = 200 then
657 | begin
658 | Add2Log('Firebase auth -> Nova Senha salva com sucesso! Realize o login novamente.');
659 | ShowMessage('Firebase auth -> Nova Senha salva com sucesso! Realize o login novamente.');
660 | TabAuth.ActivePage := TabLogin;
661 | eLoginSenha.Text := EmptyStr;
662 | eLoginUsername.Text:= EmptyStr;
663 | eLoginUsername.SetFocus;
664 | end
665 | else
666 | Begin
667 | Add2Log('Firebase auth -> Ocorreu um erro ao trocar senha. Erro: ' + ErrorMessage(TrocaSenha.Error));
668 | End;
669 | end;
670 |
671 | procedure TFormMain.btVerificarEmailEnviaCodeClick(Sender: TObject);
672 | //Este método é para enviar o código de verificação para o e-mail cadastrado do usuário
673 | var
674 | //Variavel para guardar o retorno dos métodos do Firebase Auth
675 | VerifyEmail : ieFirebaseResponseAuth;
676 | begin
677 | if fToken = EmptyStr then
678 | begin
679 | ShowMessage('Não é possível acessar o verificar e-mail sem estar logado. Faça o Login ou crie uma conta.');
680 | TabAuth.ActivePage := TabLogin;
681 | eLoginUsername.SetFocus;
682 | Exit;
683 | end;
684 |
685 | VerifyEmail := TeFirebase.New
686 | .Auth(API_Key)
687 | .SendEmailVerification(fToken);
688 |
689 | if VerifyEmail.StatusCode = 200 then
690 | begin
691 | Add2Log('Firebase auth -> Código de verificação de e-mail enviado com sucesso!');
692 | ShowMessage('Firebase auth -> Código de verificação de e-mail enviado com sucesso!!');
693 | end
694 | else
695 | Begin
696 | Add2Log('Firebase auth -> Envio de código para verificar email falhou. Erro: ' + ErrorMessage(VerifyEmail.Error));
697 | End;
698 | end;
699 |
700 | procedure TFormMain.btVerificarEmailVerificaCodeClick(Sender: TObject);
701 | //Este método é para validar o código de verificação do e-mail
702 | var
703 | //Variavel para guardar o retorno dos métodos do Firebase Auth
704 | VerifyEmail : ieFirebaseResponseAuth;
705 | begin
706 | if eVerificarEmail.Text = EmptyStr then
707 | begin
708 | ShowMessage('Não é possível verificar e-mail sem informar o código recebido pelo e-mail.');
709 | eVerificarEmail.SetFocus;
710 | Exit;
711 | end;
712 |
713 | VerifyEmail := TeFirebase.New
714 | .Auth(API_Key)
715 | .ConfirmEmailVerification(eVerificarEmail.Text);
716 |
717 | if VerifyEmail.StatusCode = 200 then
718 | begin
719 | Add2Log('Firebase auth -> E-mail verificado com sucesso!');
720 | ShowMessage('Firebase auth -> E-mail verificado com sucesso!');
721 | end
722 | else
723 | Begin
724 | Add2Log('Firebase auth -> Verificação de e-mail falhou. Erro: ' + ErrorMessage(VerifyEmail.Error));
725 | End;
726 | end;
727 |
728 | procedure TFormMain.Button1Click(Sender: TObject);
729 | begin
730 |
731 | end;
732 |
733 | procedure TFormMain.DataGridClick(Sender: TObject);
734 | begin
735 |
736 | end;
737 |
738 | procedure TFormMain.DataGridSelection(Sender: TObject; aCol, aRow: Integer);
739 | begin
740 | if DataGrid.RowCount < 1 then
741 | Exit;
742 |
743 | eFieldTask.Text := DataGrid.Cells[2, aRow];
744 | eFieldCategory.Text := DataGrid.Cells[3, aRow];
745 | fID := DataGrid.Cells[1, aRow];
746 | chFieldDone.Checked := DataGrid.Cells[0, aRow].ToBoolean;
747 | end;
748 |
749 |
750 | procedure TFormMain.btAtualizarTokenClick(Sender: TObject);
751 | //Este método é para pegar um novo token válido usando o Refresh Token (não precisa usar o Usuário e Senha novamente)
752 | var
753 | //Variavel para guardar o retorno dos métodos do Firebase Auth
754 | RefreshUser : ieFirebaseResponseAuth;
755 | begin
756 | //Verifica se há RefreshToken, se não tiver, sai, pois função não funcionaria sem RefreshToken
757 | if fRefreshToken = EmptyStr then
758 | Exit;
759 |
760 | //Chamada para executar / atualizar o RefreshToken
761 | RefreshUser := TeFirebase.New
762 | .Auth(API_Key)
763 | .ExchangeRefreshToken4idToken(fRefreshToken);
764 |
765 | //Obtendo o resultado
766 | if RefreshUser.StatusCode = 200 then
767 | begin
768 | fToken := RefreshUser.token;
769 | fRefreshToken := RefreshUser.RefreshToken;
770 |
771 | LblToken.Caption := fToken;
772 | LblRefreshToken.Caption := fRefreshToken;
773 | lblToken.WordWrap := True;
774 | lblRefreshToken.WordWrap := True;
775 | end;
776 | end;
777 |
778 | procedure TFormMain.btEnviarArquivoClick(Sender: TObject);
779 | //Este método é para enviar arquivos para o Firebase Storage
780 | var
781 | Storage : ieFirebaseStorageResponse;
782 | begin
783 | if fToken = EmptyStr then
784 | ShowMessage('Não é possível enviar arquivo sem estar logado. Realize o login e tente novamente.');
785 |
786 | if eStorageArquivo.Text = EmptyStr then
787 | Exit;
788 |
789 | Storage := TeFirebase.New
790 | .Storage(Project_ID)
791 | .Folder(eStoragePasta.Text)
792 | .FileName(eStorageArquivo.Text)
793 | .Send(fToken);
794 |
795 | if Storage.StatusCode = 200 then
796 | begin
797 | Add2Log('Firebase Storage -> Arquivo enviado com sucesso!');
798 | ShowMessage('Firebase Storage -> Arquivo enviado com sucesso!');
799 | ListBox1.Items.Add(Storage.Link);
800 | end
801 | else
802 | begin
803 | Add2Log('Firebase Storage -> Falha ao tentar enviar arquivo.');
804 | end;
805 | end;
806 |
807 | procedure TFormMain.btApagarContaClick(Sender: TObject);
808 | //Este método apaga conta do usuário
809 | var
810 | //Variavel para guardar o retorno dos métodos do Firebase Auth
811 | Profile: ieFirebaseResponseAuth;
812 | begin
813 | if fToken = EmptyStr then
814 | begin
815 | ShowMessage('Não é possível apagar conta sem estar logado. Faça o Login ou crie uma conta.');
816 | Exit;
817 | end;
818 |
819 | if MessageDlg('Deseja realmente apagar sua conta?', TMsgDlgType.mtConfirmation, mbYesNo, 0) = mrNo then
820 | Exit;
821 |
822 | try
823 | Profile := TeFirebase.New
824 | .Auth(API_Key)
825 | .DeleteAccount(fToken);
826 | except
827 | Add2Log('Firebase Auth -> Apagar Conta falhou!');
828 | end;
829 |
830 | if Profile.StatusCode = 200 then
831 | begin
832 | Add2Log('Firebase Auth -> Apagar Conta efetuado com sucesso!');
833 |
834 | ShowMessage('Conta excluída com sucesso.');
835 | end
836 | else
837 | begin
838 | Add2Log('Firebase Auth -> Apagar Conta falhou: ' + ErrorMessage(Profile.Error) + #13 + 'Status Code = ' + Profile.StatusCode.ToString);
839 | ShowMessage('Firebase Auth -> Apagar Conta falhou: ' + ErrorMessage(Profile.Error) + #13 + 'Status Code = ' + Profile.StatusCode.ToString);
840 | end;
841 | end;
842 |
843 | procedure TFormMain.btExibirPerfilClick(Sender: TObject);
844 | //Este método irá exibir as informações da conta do usuário logado
845 | var
846 | //Variavel para guardar o retorno dos métodos do Firebase Auth
847 | Profile : ieFirebaseResponseAuth;
848 | begin
849 | if fToken = EmptyStr then
850 | begin
851 | ShowMessage('Não é possível acessar o profile sem estar logado. Faça o Login ou crie uma conta.');
852 | TabAuth.ActivePage := TabLogin;
853 | eLoginUsername.SetFocus;
854 | Exit;
855 | end;
856 |
857 | try
858 | Profile := TeFirebase.New
859 | .Auth(API_Key)
860 | .GetProfile(fToken);
861 | except
862 | Add2Log('Firebase Auth -> Get Profile falhou!');
863 | end;
864 |
865 | if Profile.StatusCode = 200 then
866 | begin
867 | Add2Log('Firebase Auth -> Get Profile efetuado com sucesso!');
868 |
869 | LblPerfiluID.Caption := Profile.uID;
870 | LblPerfilEmail.Caption := Profile.Email;
871 | ePerfilNome.Text := Profile.DisplayName;
872 | ePerfilURLFoto.Text := Profile.photoUrl;
873 | LblPerfilCriado.Caption := Profile.createdAt;
874 | lblPerfilUltimoAcesso.Caption := Profile.lastLoginAt;
875 |
876 | if Profile.EmailVerified then
877 | lblPerfilEmailVerificado.Caption := 'E-mail verificado'
878 | else
879 | lblPerfilEmailVerificado.Caption := 'E-mail NÃO verificado!';
880 | end
881 | else
882 | begin
883 | Add2Log('Firebase Auth -> Get Profile falhou: ' + ErrorMessage(Profile.Error) + #13 + 'Status Code = ' + Profile.StatusCode.ToString);
884 | ShowMessage('Firebase Auth -> Get Profile falhou: ' + ErrorMessage(Profile.Error) + #13 + 'Status Code = ' + Profile.StatusCode.ToString);
885 | end;
886 | end;
887 |
888 | {$EndRegion}
889 |
890 | end.
891 |
892 |
--------------------------------------------------------------------------------
/Demos/Lazarus/Simple Demo/unitmain.lfm:
--------------------------------------------------------------------------------
1 | object FormMain: TFormMain
2 | Left = 335
3 | Height = 786
4 | Top = 172
5 | Width = 1231
6 | BorderIcons = [biSystemMenu, biMinimize]
7 | BorderStyle = bsSingle
8 | Caption = 'Simple Demo'
9 | ClientHeight = 786
10 | ClientWidth = 1231
11 | DesignTimePPI = 120
12 | OnCreate = FormCreate
13 | OnShow = FormShow
14 | Position = poDesktopCenter
15 | LCLVersion = '2.2.6.0'
16 | object TabServices: TPageControl
17 | Left = 15
18 | Height = 595
19 | Top = 15
20 | Width = 1201
21 | ActivePage = TabFirebaseAuth
22 | Align = alClient
23 | BorderSpacing.Around = 15
24 | TabIndex = 0
25 | TabOrder = 0
26 | object TabFirebaseAuth: TTabSheet
27 | Caption = 'Firebase Auth'
28 | ClientHeight = 562
29 | ClientWidth = 1193
30 | object TabAuth: TPageControl
31 | Left = 30
32 | Height = 502
33 | Top = 30
34 | Width = 1133
35 | ActivePage = TabLogin
36 | Align = alClient
37 | BorderSpacing.Around = 30
38 | TabIndex = 0
39 | TabOrder = 0
40 | TabPosition = tpBottom
41 | object TabLogin: TTabSheet
42 | Caption = 'Login'
43 | ClientHeight = 469
44 | ClientWidth = 1125
45 | object GroupLogin: TGroupBox
46 | Left = 10
47 | Height = 252
48 | Top = 10
49 | Width = 1105
50 | Align = alClient
51 | BorderSpacing.Around = 10
52 | Caption = ' Efetuar Login '
53 | ClientHeight = 227
54 | ClientWidth = 1101
55 | TabOrder = 0
56 | object layoutUserName: TPanel
57 | Left = 10
58 | Height = 63
59 | Top = 10
60 | Width = 1081
61 | Align = alTop
62 | BorderSpacing.Around = 10
63 | BevelOuter = bvNone
64 | ClientHeight = 63
65 | ClientWidth = 1081
66 | TabOrder = 0
67 | object lblLoginUsername: TLabel
68 | Left = 0
69 | Height = 63
70 | Top = 0
71 | Width = 120
72 | Align = alLeft
73 | Alignment = taCenter
74 | AutoSize = False
75 | Caption = 'Usuário'
76 | Layout = tlCenter
77 | ParentColor = False
78 | end
79 | object eLoginUsername: TEdit
80 | Left = 135
81 | Height = 33
82 | Top = 15
83 | Width = 931
84 | Align = alClient
85 | BorderSpacing.Around = 15
86 | Font.CharSet = ANSI_CHARSET
87 | Font.Height = -18
88 | Font.Pitch = fpVariable
89 | Font.Quality = fqDraft
90 | ParentFont = False
91 | TabOrder = 0
92 | TextHint = 'Digite aqui o seu usuário'
93 | end
94 | end
95 | object layoutUserName1: TPanel
96 | Left = 10
97 | Height = 63
98 | Top = 83
99 | Width = 1081
100 | Align = alTop
101 | BorderSpacing.Around = 10
102 | BevelOuter = bvNone
103 | ClientHeight = 63
104 | ClientWidth = 1081
105 | TabOrder = 1
106 | object lblLoginSenha: TLabel
107 | Left = 0
108 | Height = 63
109 | Top = 0
110 | Width = 120
111 | Align = alLeft
112 | Alignment = taCenter
113 | AutoSize = False
114 | Caption = 'Senha'
115 | Layout = tlCenter
116 | ParentColor = False
117 | end
118 | object eLoginSenha: TEdit
119 | Left = 135
120 | Height = 33
121 | Top = 15
122 | Width = 931
123 | Align = alClient
124 | BorderSpacing.Around = 15
125 | EchoMode = emPassword
126 | Font.CharSet = ANSI_CHARSET
127 | Font.Height = -18
128 | Font.Pitch = fpVariable
129 | Font.Quality = fqDraft
130 | ParentFont = False
131 | PasswordChar = '*'
132 | TabOrder = 0
133 | TextHint = 'Digite aqui sua senha'
134 | end
135 | end
136 | object layoutUserName2: TPanel
137 | Left = 10
138 | Height = 63
139 | Top = 156
140 | Width = 1081
141 | Align = alTop
142 | BorderSpacing.Around = 10
143 | BevelOuter = bvNone
144 | ClientHeight = 63
145 | ClientWidth = 1081
146 | TabOrder = 2
147 | object btLoginEntrar: TButton
148 | Left = 896
149 | Height = 53
150 | Top = 5
151 | Width = 170
152 | Align = alRight
153 | BorderSpacing.Right = 10
154 | BorderSpacing.Around = 5
155 | Caption = '&Entrar'
156 | OnClick = btLoginEntrarClick
157 | TabOrder = 0
158 | end
159 | end
160 | end
161 | object GroupTokens: TGroupBox
162 | Left = 10
163 | Height = 187
164 | Top = 272
165 | Width = 1105
166 | Align = alBottom
167 | BorderSpacing.Around = 10
168 | Caption = ' Tokens '
169 | ClientHeight = 162
170 | ClientWidth = 1101
171 | TabOrder = 1
172 | object layoutUserName3: TPanel
173 | Left = 10
174 | Height = 63
175 | Top = 10
176 | Width = 1081
177 | Align = alTop
178 | BorderSpacing.Around = 10
179 | BevelOuter = bvNone
180 | ClientHeight = 63
181 | ClientWidth = 1081
182 | TabOrder = 0
183 | object lblLoginSenha1: TLabel
184 | Left = 0
185 | Height = 63
186 | Top = 0
187 | Width = 120
188 | Align = alLeft
189 | Alignment = taCenter
190 | AutoSize = False
191 | Caption = 'Token'
192 | Layout = tlCenter
193 | ParentColor = False
194 | end
195 | object lblToken: TLabel
196 | Left = 120
197 | Height = 63
198 | Top = 0
199 | Width = 961
200 | Align = alClient
201 | Alignment = taCenter
202 | AutoSize = False
203 | Font.CharSet = ANSI_CHARSET
204 | Font.Pitch = fpVariable
205 | Font.Quality = fqDraft
206 | Font.Style = [fsBold]
207 | Layout = tlCenter
208 | ParentColor = False
209 | ParentFont = False
210 | WordWrap = True
211 | end
212 | end
213 | object layoutUserName4: TPanel
214 | Left = 10
215 | Height = 63
216 | Top = 83
217 | Width = 1081
218 | Align = alTop
219 | BorderSpacing.Around = 10
220 | BevelOuter = bvNone
221 | ClientHeight = 63
222 | ClientWidth = 1081
223 | TabOrder = 1
224 | object btAtualizarToken: TButton
225 | Left = 896
226 | Height = 53
227 | Top = 5
228 | Width = 170
229 | Align = alRight
230 | BorderSpacing.Right = 10
231 | BorderSpacing.Around = 5
232 | Caption = 'Atualizar Token'
233 | OnClick = btAtualizarTokenClick
234 | TabOrder = 0
235 | end
236 | object lblLoginSenha2: TLabel
237 | Left = 0
238 | Height = 63
239 | Top = 0
240 | Width = 120
241 | Align = alLeft
242 | Alignment = taCenter
243 | AutoSize = False
244 | Caption = 'Refresh Token'
245 | Layout = tlCenter
246 | ParentColor = False
247 | end
248 | object lblRefreshToken: TLabel
249 | Left = 120
250 | Height = 63
251 | Top = 0
252 | Width = 771
253 | Align = alClient
254 | Alignment = taCenter
255 | AutoSize = False
256 | Font.CharSet = ANSI_CHARSET
257 | Font.Pitch = fpVariable
258 | Font.Quality = fqDraft
259 | Font.Style = [fsBold]
260 | Layout = tlCenter
261 | ParentColor = False
262 | ParentFont = False
263 | WordWrap = True
264 | end
265 | end
266 | end
267 | end
268 | object TabRegister: TTabSheet
269 | Caption = 'Registrar'
270 | ClientHeight = 469
271 | ClientWidth = 1125
272 | object GroupRegistro: TGroupBox
273 | Left = 10
274 | Height = 262
275 | Top = 10
276 | Width = 1105
277 | Align = alTop
278 | BorderSpacing.Around = 10
279 | Caption = ' Registrar Conta / Novo usuário '
280 | ClientHeight = 237
281 | ClientWidth = 1101
282 | TabOrder = 0
283 | object layoutUserName5: TPanel
284 | Left = 10
285 | Height = 63
286 | Top = 10
287 | Width = 1081
288 | Align = alTop
289 | BorderSpacing.Around = 10
290 | BevelOuter = bvNone
291 | ClientHeight = 63
292 | ClientWidth = 1081
293 | TabOrder = 0
294 | object lblLoginUsername1: TLabel
295 | Left = 0
296 | Height = 63
297 | Top = 0
298 | Width = 120
299 | Align = alLeft
300 | Alignment = taCenter
301 | AutoSize = False
302 | Caption = 'Usuário'
303 | Layout = tlCenter
304 | ParentColor = False
305 | end
306 | object eRegistroUsername: TEdit
307 | Left = 135
308 | Height = 33
309 | Top = 15
310 | Width = 931
311 | Align = alClient
312 | BorderSpacing.Around = 15
313 | Font.CharSet = ANSI_CHARSET
314 | Font.Height = -18
315 | Font.Pitch = fpVariable
316 | Font.Quality = fqDraft
317 | ParentFont = False
318 | TabOrder = 0
319 | TextHint = 'Digite aqui o seu usuário'
320 | end
321 | end
322 | object layoutUserName6: TPanel
323 | Left = 10
324 | Height = 63
325 | Top = 83
326 | Width = 1081
327 | Align = alTop
328 | BorderSpacing.Around = 10
329 | BevelOuter = bvNone
330 | ClientHeight = 63
331 | ClientWidth = 1081
332 | TabOrder = 1
333 | object lblLoginSenha3: TLabel
334 | Left = 0
335 | Height = 63
336 | Top = 0
337 | Width = 120
338 | Align = alLeft
339 | Alignment = taCenter
340 | AutoSize = False
341 | Caption = 'Senha'
342 | Layout = tlCenter
343 | ParentColor = False
344 | end
345 | object eRegistroSenha: TEdit
346 | Left = 135
347 | Height = 33
348 | Top = 15
349 | Width = 931
350 | Align = alClient
351 | BorderSpacing.Around = 15
352 | EchoMode = emPassword
353 | Font.CharSet = ANSI_CHARSET
354 | Font.Height = -18
355 | Font.Pitch = fpVariable
356 | Font.Quality = fqDraft
357 | ParentFont = False
358 | PasswordChar = '*'
359 | TabOrder = 0
360 | TextHint = 'Digite aqui sua senha'
361 | end
362 | end
363 | object layoutUserName7: TPanel
364 | Left = 10
365 | Height = 63
366 | Top = 156
367 | Width = 1081
368 | Align = alTop
369 | BorderSpacing.Around = 10
370 | BevelOuter = bvNone
371 | ClientHeight = 63
372 | ClientWidth = 1081
373 | TabOrder = 2
374 | object btRegistroRegistrar: TButton
375 | Left = 896
376 | Height = 53
377 | Top = 5
378 | Width = 170
379 | Align = alRight
380 | BorderSpacing.Right = 10
381 | BorderSpacing.Around = 5
382 | Caption = '&Registrar'
383 | OnClick = btRegistroRegistrarClick
384 | TabOrder = 0
385 | end
386 | end
387 | end
388 | end
389 | object TabReset: TTabSheet
390 | Caption = 'Resetar / Trocar senha'
391 | ClientHeight = 469
392 | ClientWidth = 1125
393 | object GroupLogin1: TGroupBox
394 | Left = 10
395 | Height = 252
396 | Top = 10
397 | Width = 1105
398 | Align = alClient
399 | BorderSpacing.Around = 10
400 | Caption = ' Resetar senha, enviar código; verificar e confirmar código e trocar senha '
401 | ClientHeight = 227
402 | ClientWidth = 1101
403 | TabOrder = 0
404 | object layoutUserName8: TPanel
405 | Left = 10
406 | Height = 63
407 | Top = 10
408 | Width = 1081
409 | Align = alTop
410 | BorderSpacing.Around = 10
411 | BevelOuter = bvNone
412 | ClientHeight = 63
413 | ClientWidth = 1081
414 | TabOrder = 0
415 | object lblLoginUsername2: TLabel
416 | Left = 0
417 | Height = 63
418 | Top = 0
419 | Width = 120
420 | Align = alLeft
421 | Alignment = taCenter
422 | AutoSize = False
423 | Caption = 'E-mail'
424 | Layout = tlCenter
425 | ParentColor = False
426 | end
427 | object eResetEmail: TEdit
428 | Left = 135
429 | Height = 33
430 | Top = 15
431 | Width = 746
432 | Align = alClient
433 | BorderSpacing.Around = 15
434 | Font.CharSet = ANSI_CHARSET
435 | Font.Height = -18
436 | Font.Pitch = fpVariable
437 | Font.Quality = fqDraft
438 | ParentFont = False
439 | TabOrder = 0
440 | TextHint = 'Digite aqui o seu e-mail'
441 | end
442 | object btResetResetar: TButton
443 | Left = 896
444 | Height = 53
445 | Top = 5
446 | Width = 170
447 | Align = alRight
448 | BorderSpacing.Right = 10
449 | BorderSpacing.Around = 5
450 | Caption = '&Resetar'
451 | OnClick = btResetResetarClick
452 | TabOrder = 1
453 | end
454 | end
455 | object layoutUserName9: TPanel
456 | Left = 10
457 | Height = 63
458 | Top = 83
459 | Width = 1081
460 | Align = alTop
461 | BorderSpacing.Around = 10
462 | BevelOuter = bvNone
463 | ClientHeight = 63
464 | ClientWidth = 1081
465 | TabOrder = 1
466 | object lblLoginSenha4: TLabel
467 | Left = 0
468 | Height = 63
469 | Top = 0
470 | Width = 120
471 | Align = alLeft
472 | Alignment = taCenter
473 | AutoSize = False
474 | Caption = 'Código de Resetamento'
475 | Layout = tlCenter
476 | ParentColor = False
477 | WordWrap = True
478 | end
479 | object eResetCode: TEdit
480 | Left = 135
481 | Height = 33
482 | Top = 15
483 | Width = 746
484 | Align = alClient
485 | BorderSpacing.Around = 15
486 | Font.CharSet = ANSI_CHARSET
487 | Font.Height = -18
488 | Font.Pitch = fpVariable
489 | Font.Quality = fqDraft
490 | ParentFont = False
491 | TabOrder = 0
492 | TextHint = 'Digite aqui o código enviado para seu e-mail'
493 | end
494 | object btResetVerificar: TButton
495 | Left = 896
496 | Height = 53
497 | Top = 5
498 | Width = 170
499 | Align = alRight
500 | BorderSpacing.Right = 10
501 | BorderSpacing.Around = 5
502 | Caption = '&Verificar'
503 | OnClick = btResetVerificarClick
504 | TabOrder = 1
505 | end
506 | end
507 | object layoutUserName10: TPanel
508 | Left = 10
509 | Height = 63
510 | Top = 156
511 | Width = 1081
512 | Align = alTop
513 | BorderSpacing.Around = 10
514 | BevelOuter = bvNone
515 | ClientHeight = 63
516 | ClientWidth = 1081
517 | TabOrder = 2
518 | object btResetConfirmar: TButton
519 | Left = 896
520 | Height = 53
521 | Top = 5
522 | Width = 170
523 | Align = alRight
524 | BorderSpacing.Right = 10
525 | BorderSpacing.Around = 5
526 | Caption = '&Confirmar'
527 | OnClick = btResetConfirmarClick
528 | TabOrder = 0
529 | end
530 | object lblLoginSenha7: TLabel
531 | Left = 0
532 | Height = 63
533 | Top = 0
534 | Width = 120
535 | Align = alLeft
536 | Alignment = taCenter
537 | AutoSize = False
538 | Caption = 'Nova Senha'
539 | Layout = tlCenter
540 | ParentColor = False
541 | end
542 | object eResetNovaSenha: TEdit
543 | Left = 135
544 | Height = 33
545 | Top = 15
546 | Width = 746
547 | Align = alClient
548 | BorderSpacing.Around = 15
549 | EchoMode = emPassword
550 | Font.CharSet = ANSI_CHARSET
551 | Font.Height = -18
552 | Font.Pitch = fpVariable
553 | Font.Quality = fqDraft
554 | ParentFont = False
555 | PasswordChar = '*'
556 | TabOrder = 1
557 | TextHint = 'Digite aqui sua nova senha'
558 | end
559 | end
560 | end
561 | object GroupTokens1: TGroupBox
562 | Left = 10
563 | Height = 187
564 | Top = 272
565 | Width = 1105
566 | Align = alBottom
567 | BorderSpacing.Around = 10
568 | Caption = ' Trocar senha '
569 | ClientHeight = 162
570 | ClientWidth = 1101
571 | TabOrder = 1
572 | object layoutUserName11: TPanel
573 | Left = 10
574 | Height = 63
575 | Top = 10
576 | Width = 1081
577 | Align = alTop
578 | BorderSpacing.Around = 10
579 | BevelOuter = bvNone
580 | ClientHeight = 63
581 | ClientWidth = 1081
582 | TabOrder = 0
583 | object lblLoginSenha5: TLabel
584 | Left = 0
585 | Height = 63
586 | Top = 0
587 | Width = 120
588 | Align = alLeft
589 | Alignment = taCenter
590 | AutoSize = False
591 | Caption = 'Senha'
592 | Layout = tlCenter
593 | ParentColor = False
594 | end
595 | object eTrocarSenha: TEdit
596 | Left = 135
597 | Height = 33
598 | Top = 15
599 | Width = 931
600 | Align = alClient
601 | BorderSpacing.Around = 15
602 | EchoMode = emPassword
603 | Font.CharSet = ANSI_CHARSET
604 | Font.Height = -18
605 | Font.Pitch = fpVariable
606 | Font.Quality = fqDraft
607 | ParentFont = False
608 | PasswordChar = '*'
609 | TabOrder = 0
610 | TextHint = 'Digite aqui sua nova senha'
611 | end
612 | end
613 | object layoutUserName12: TPanel
614 | Left = 10
615 | Height = 63
616 | Top = 83
617 | Width = 1081
618 | Align = alTop
619 | BorderSpacing.Around = 10
620 | BevelOuter = bvNone
621 | ClientHeight = 63
622 | ClientWidth = 1081
623 | TabOrder = 1
624 | object btTrocarSenha: TButton
625 | Left = 896
626 | Height = 53
627 | Top = 5
628 | Width = 170
629 | Align = alRight
630 | BorderSpacing.Right = 10
631 | BorderSpacing.Around = 5
632 | Caption = '&Trocar Senha'
633 | OnClick = btTrocarSenhaClick
634 | TabOrder = 0
635 | end
636 | end
637 | end
638 | end
639 | object TabPerfil: TTabSheet
640 | Caption = 'Perfil'
641 | ClientHeight = 469
642 | ClientWidth = 1125
643 | object GroupLogin2: TGroupBox
644 | Left = 15
645 | Height = 439
646 | Top = 15
647 | Width = 1095
648 | Align = alClient
649 | BorderSpacing.Around = 15
650 | Caption = ' Exibindo informações do Perfil '
651 | ClientHeight = 414
652 | ClientWidth = 1091
653 | TabOrder = 0
654 | object layoutUserName13: TPanel
655 | Left = 10
656 | Height = 63
657 | Top = 10
658 | Width = 1071
659 | Align = alTop
660 | BorderSpacing.Left = 10
661 | BorderSpacing.Top = 10
662 | BorderSpacing.Right = 10
663 | BevelOuter = bvNone
664 | ClientHeight = 63
665 | ClientWidth = 1071
666 | TabOrder = 0
667 | object lblLoginUsername3: TLabel
668 | Left = 0
669 | Height = 63
670 | Top = 0
671 | Width = 120
672 | Align = alLeft
673 | Alignment = taCenter
674 | AutoSize = False
675 | Caption = 'ID'
676 | Layout = tlCenter
677 | ParentColor = False
678 | end
679 | object lblPerfiluID: TLabel
680 | Left = 120
681 | Height = 63
682 | Top = 0
683 | Width = 951
684 | Align = alClient
685 | Font.CharSet = ANSI_CHARSET
686 | Font.Pitch = fpVariable
687 | Font.Quality = fqDraft
688 | Font.Style = [fsBold]
689 | Layout = tlCenter
690 | ParentColor = False
691 | ParentFont = False
692 | end
693 | end
694 | object layoutUserName14: TPanel
695 | Left = 10
696 | Height = 63
697 | Top = 78
698 | Width = 1071
699 | Align = alTop
700 | BorderSpacing.Left = 10
701 | BorderSpacing.Top = 5
702 | BorderSpacing.Right = 10
703 | BevelOuter = bvNone
704 | ClientHeight = 63
705 | ClientWidth = 1071
706 | TabOrder = 1
707 | object lblLoginSenha6: TLabel
708 | Left = 0
709 | Height = 63
710 | Top = 0
711 | Width = 120
712 | Align = alLeft
713 | Alignment = taCenter
714 | AutoSize = False
715 | Caption = 'E-mail'
716 | Layout = tlCenter
717 | ParentColor = False
718 | WordWrap = True
719 | end
720 | object lblPerfilEmail: TLabel
721 | Left = 120
722 | Height = 63
723 | Top = 0
724 | Width = 951
725 | Align = alClient
726 | Font.CharSet = ANSI_CHARSET
727 | Font.Pitch = fpVariable
728 | Font.Quality = fqDraft
729 | Font.Style = [fsBold]
730 | Layout = tlCenter
731 | ParentColor = False
732 | ParentFont = False
733 | end
734 | end
735 | object layoutUserName15: TPanel
736 | Left = 10
737 | Height = 63
738 | Top = 146
739 | Width = 1071
740 | Align = alTop
741 | BorderSpacing.Left = 10
742 | BorderSpacing.Top = 5
743 | BorderSpacing.Right = 10
744 | BevelOuter = bvNone
745 | ClientHeight = 63
746 | ClientWidth = 1071
747 | TabOrder = 2
748 | object lblLoginSenha8: TLabel
749 | Left = 0
750 | Height = 63
751 | Top = 0
752 | Width = 120
753 | Align = alLeft
754 | Alignment = taCenter
755 | AutoSize = False
756 | Caption = 'Nome'
757 | Layout = tlCenter
758 | ParentColor = False
759 | end
760 | object ePerfilNome: TEdit
761 | Left = 135
762 | Height = 33
763 | Top = 15
764 | Width = 921
765 | Align = alClient
766 | BorderSpacing.Around = 15
767 | Font.CharSet = ANSI_CHARSET
768 | Font.Height = -18
769 | Font.Pitch = fpVariable
770 | Font.Quality = fqDraft
771 | ParentFont = False
772 | TabOrder = 0
773 | TextHint = 'Digite aqui o nome de exibição da conta'
774 | end
775 | end
776 | object layoutUserName16: TPanel
777 | Left = 10
778 | Height = 63
779 | Top = 214
780 | Width = 1071
781 | Align = alTop
782 | BorderSpacing.Left = 10
783 | BorderSpacing.Top = 5
784 | BorderSpacing.Right = 10
785 | BevelOuter = bvNone
786 | ClientHeight = 63
787 | ClientWidth = 1071
788 | TabOrder = 3
789 | object lblLoginSenha9: TLabel
790 | Left = 0
791 | Height = 63
792 | Top = 0
793 | Width = 120
794 | Align = alLeft
795 | Alignment = taCenter
796 | AutoSize = False
797 | Caption = 'URL Foto'
798 | Layout = tlCenter
799 | ParentColor = False
800 | end
801 | object ePerfilURLFoto: TEdit
802 | Left = 135
803 | Height = 33
804 | Top = 15
805 | Width = 921
806 | Align = alClient
807 | BorderSpacing.Around = 15
808 | Font.CharSet = ANSI_CHARSET
809 | Font.Height = -18
810 | Font.Pitch = fpVariable
811 | Font.Quality = fqDraft
812 | ParentFont = False
813 | TabOrder = 0
814 | TextHint = 'Informe a URL da foto de perfil (URL do Firebase Storage, por exemplo)'
815 | end
816 | end
817 | object layoutUserName17: TPanel
818 | Left = 10
819 | Height = 63
820 | Top = 282
821 | Width = 1071
822 | Align = alTop
823 | BorderSpacing.Left = 10
824 | BorderSpacing.Top = 5
825 | BorderSpacing.Right = 10
826 | BevelOuter = bvNone
827 | ClientHeight = 63
828 | ClientWidth = 1071
829 | TabOrder = 4
830 | object lblLoginSenha10: TLabel
831 | Left = 0
832 | Height = 63
833 | Top = 0
834 | Width = 120
835 | Align = alLeft
836 | Alignment = taCenter
837 | AutoSize = False
838 | Caption = 'Criado em'
839 | Layout = tlCenter
840 | ParentColor = False
841 | WordWrap = True
842 | end
843 | object lblPerfilCriado: TLabel
844 | Left = 120
845 | Height = 63
846 | Top = 0
847 | Width = 235
848 | Align = alLeft
849 | AutoSize = False
850 | Font.CharSet = ANSI_CHARSET
851 | Font.Pitch = fpVariable
852 | Font.Quality = fqDraft
853 | Font.Style = [fsBold]
854 | Layout = tlCenter
855 | ParentColor = False
856 | ParentFont = False
857 | end
858 | object lblLoginSenha11: TLabel
859 | Left = 702
860 | Height = 63
861 | Top = 0
862 | Width = 117
863 | Align = alRight
864 | Alignment = taCenter
865 | AutoSize = False
866 | Caption = 'Último acesso'
867 | Layout = tlCenter
868 | ParentColor = False
869 | WordWrap = True
870 | end
871 | object lblPerfilUltimoAcesso: TLabel
872 | Left = 819
873 | Height = 63
874 | Top = 0
875 | Width = 252
876 | Align = alRight
877 | AutoSize = False
878 | Font.CharSet = ANSI_CHARSET
879 | Font.Pitch = fpVariable
880 | Font.Quality = fqDraft
881 | Font.Style = [fsBold]
882 | Layout = tlCenter
883 | ParentColor = False
884 | ParentFont = False
885 | end
886 | end
887 | object layoutUserName18: TPanel
888 | Left = 10
889 | Height = 63
890 | Top = 350
891 | Width = 1071
892 | Align = alTop
893 | BorderSpacing.Left = 10
894 | BorderSpacing.Top = 5
895 | BorderSpacing.Right = 10
896 | BevelOuter = bvNone
897 | ClientHeight = 63
898 | ClientWidth = 1071
899 | TabOrder = 5
900 | object btExibirPerfil: TButton
901 | Left = 701
902 | Height = 53
903 | Top = 5
904 | Width = 170
905 | Align = alRight
906 | BorderSpacing.Right = 10
907 | BorderSpacing.Around = 5
908 | Caption = '&Exibir Perfil'
909 | OnClick = btExibirPerfilClick
910 | TabOrder = 0
911 | end
912 | object btSalvarPerfil: TButton
913 | Left = 886
914 | Height = 53
915 | Top = 5
916 | Width = 170
917 | Align = alRight
918 | BorderSpacing.Right = 10
919 | BorderSpacing.Around = 5
920 | Caption = '&Salvar Alterações'
921 | OnClick = btSalvarPerfilClick
922 | TabOrder = 1
923 | end
924 | object lblPerfilEmailVerificado: TLabel
925 | Left = 10
926 | Height = 43
927 | Top = 10
928 | Width = 1
929 | Align = alLeft
930 | BorderSpacing.Around = 10
931 | Font.CharSet = ANSI_CHARSET
932 | Font.Height = -17
933 | Font.Pitch = fpVariable
934 | Font.Quality = fqDraft
935 | Font.Style = [fsBold]
936 | Layout = tlCenter
937 | ParentColor = False
938 | ParentFont = False
939 | end
940 | end
941 | end
942 | end
943 | object TabVerificarEmail: TTabSheet
944 | Caption = 'Verificar e-mail'
945 | ClientHeight = 469
946 | ClientWidth = 1125
947 | object GroupTokens2: TGroupBox
948 | Left = 10
949 | Height = 187
950 | Top = 10
951 | Width = 1105
952 | Align = alTop
953 | BorderSpacing.Around = 10
954 | Caption = ' Verificar e-mail da conta '
955 | ClientHeight = 162
956 | ClientWidth = 1101
957 | TabOrder = 0
958 | object layoutUserName19: TPanel
959 | Left = 10
960 | Height = 63
961 | Top = 10
962 | Width = 1081
963 | Align = alTop
964 | BorderSpacing.Around = 10
965 | BevelOuter = bvNone
966 | ClientHeight = 63
967 | ClientWidth = 1081
968 | TabOrder = 0
969 | object lblLoginSenha12: TLabel
970 | Left = 0
971 | Height = 63
972 | Top = 0
973 | Width = 120
974 | Align = alLeft
975 | Alignment = taCenter
976 | AutoSize = False
977 | Caption = 'Código'
978 | Layout = tlCenter
979 | ParentColor = False
980 | end
981 | object eVerificarEmail: TEdit
982 | Left = 135
983 | Height = 33
984 | Top = 15
985 | Width = 931
986 | Align = alClient
987 | BorderSpacing.Around = 15
988 | Font.CharSet = ANSI_CHARSET
989 | Font.Height = -18
990 | Font.Pitch = fpVariable
991 | Font.Quality = fqDraft
992 | ParentFont = False
993 | TabOrder = 0
994 | TextHint = 'Digite aqui o código de verificação'
995 | end
996 | end
997 | object layoutUserName20: TPanel
998 | Left = 10
999 | Height = 63
1000 | Top = 83
1001 | Width = 1081
1002 | Align = alTop
1003 | BorderSpacing.Around = 10
1004 | BevelOuter = bvNone
1005 | ClientHeight = 63
1006 | ClientWidth = 1081
1007 | TabOrder = 1
1008 | object btVerificarEmailEnviaCode: TButton
1009 | Left = 721
1010 | Height = 53
1011 | Top = 5
1012 | Width = 170
1013 | Align = alRight
1014 | BorderSpacing.Around = 5
1015 | Caption = '&Enviar Código'
1016 | OnClick = btVerificarEmailEnviaCodeClick
1017 | TabOrder = 0
1018 | end
1019 | object btVerificarEmailVerificaCode: TButton
1020 | Left = 896
1021 | Height = 53
1022 | Top = 5
1023 | Width = 170
1024 | Align = alRight
1025 | BorderSpacing.Right = 10
1026 | BorderSpacing.Around = 5
1027 | Caption = '&Verificar E-mail'
1028 | OnClick = btVerificarEmailVerificaCodeClick
1029 | TabOrder = 1
1030 | end
1031 | end
1032 | end
1033 | end
1034 | object TabApagarConta: TTabSheet
1035 | Caption = 'Apagar Conta'
1036 | ClientHeight = 469
1037 | ClientWidth = 1125
1038 | object btApagarConta: TButton
1039 | Left = 328
1040 | Height = 144
1041 | Top = 120
1042 | Width = 374
1043 | Caption = 'Apagar Conta'
1044 | OnClick = btApagarContaClick
1045 | TabOrder = 0
1046 | end
1047 | end
1048 | end
1049 | end
1050 | object TabFirebaseStorage: TTabSheet
1051 | Caption = 'Firebase Storage'
1052 | ClientHeight = 562
1053 | ClientWidth = 1193
1054 | object GroupBox2: TGroupBox
1055 | Left = 20
1056 | Height = 251
1057 | Top = 20
1058 | Width = 1153
1059 | Align = alTop
1060 | BorderSpacing.Around = 20
1061 | Caption = 'Enviar arquivo para Firebase Storage '
1062 | ClientHeight = 226
1063 | ClientWidth = 1149
1064 | TabOrder = 0
1065 | object layoutUserName21: TPanel
1066 | Left = 10
1067 | Height = 63
1068 | Top = 10
1069 | Width = 1129
1070 | Align = alTop
1071 | BorderSpacing.Around = 10
1072 | BevelOuter = bvNone
1073 | ClientHeight = 63
1074 | ClientWidth = 1129
1075 | TabOrder = 0
1076 | object lblLoginUsername4: TLabel
1077 | Left = 0
1078 | Height = 63
1079 | Top = 0
1080 | Width = 120
1081 | Align = alLeft
1082 | Alignment = taCenter
1083 | AutoSize = False
1084 | Caption = 'Pasta'
1085 | Layout = tlCenter
1086 | ParentColor = False
1087 | end
1088 | object eStoragePasta: TEdit
1089 | Left = 135
1090 | Height = 33
1091 | Top = 15
1092 | Width = 979
1093 | Align = alClient
1094 | BorderSpacing.Around = 15
1095 | Font.CharSet = ANSI_CHARSET
1096 | Font.Height = -18
1097 | Font.Pitch = fpVariable
1098 | Font.Quality = fqDraft
1099 | ParentFont = False
1100 | TabOrder = 0
1101 | TextHint = 'informe a pasta a enviar o arquivo'
1102 | end
1103 | end
1104 | object layoutUserName22: TPanel
1105 | Left = 10
1106 | Height = 63
1107 | Top = 83
1108 | Width = 1129
1109 | Align = alTop
1110 | BorderSpacing.Around = 10
1111 | BevelOuter = bvNone
1112 | ClientHeight = 63
1113 | ClientWidth = 1129
1114 | TabOrder = 1
1115 | object lblLoginSenha13: TLabel
1116 | Left = 0
1117 | Height = 63
1118 | Top = 0
1119 | Width = 120
1120 | Align = alLeft
1121 | Alignment = taCenter
1122 | AutoSize = False
1123 | Caption = 'Arquivo'
1124 | Layout = tlCenter
1125 | ParentColor = False
1126 | end
1127 | object eStorageArquivo: TEdit
1128 | Left = 135
1129 | Height = 33
1130 | Top = 15
1131 | Width = 794
1132 | Align = alClient
1133 | BorderSpacing.Around = 15
1134 | Font.CharSet = ANSI_CHARSET
1135 | Font.Height = -18
1136 | Font.Pitch = fpVariable
1137 | Font.Quality = fqDraft
1138 | ParentFont = False
1139 | TabOrder = 0
1140 | TextHint = 'Informe local e nome do arquivo a enviar'
1141 | end
1142 | object btProcurarArquivo: TButton
1143 | Left = 944
1144 | Height = 53
1145 | Top = 5
1146 | Width = 170
1147 | Align = alRight
1148 | BorderSpacing.Right = 10
1149 | BorderSpacing.Around = 5
1150 | Caption = '&Escolher arquivo'
1151 | OnClick = btProcurarArquivoClick
1152 | TabOrder = 1
1153 | end
1154 | end
1155 | object layoutUserName23: TPanel
1156 | Left = 10
1157 | Height = 63
1158 | Top = 156
1159 | Width = 1129
1160 | Align = alTop
1161 | BorderSpacing.Around = 10
1162 | BevelOuter = bvNone
1163 | ClientHeight = 63
1164 | ClientWidth = 1129
1165 | TabOrder = 2
1166 | object btEnviarArquivo: TButton
1167 | Left = 944
1168 | Height = 53
1169 | Top = 5
1170 | Width = 170
1171 | Align = alRight
1172 | BorderSpacing.Right = 10
1173 | BorderSpacing.Around = 5
1174 | Caption = '&Enviar Arquivo'
1175 | OnClick = btEnviarArquivoClick
1176 | TabOrder = 0
1177 | end
1178 | end
1179 | end
1180 | object GroupBox3: TGroupBox
1181 | Left = 20
1182 | Height = 251
1183 | Top = 291
1184 | Width = 1153
1185 | Align = alClient
1186 | BorderSpacing.Around = 20
1187 | Caption = ' Exibição '
1188 | ClientHeight = 226
1189 | ClientWidth = 1149
1190 | TabOrder = 1
1191 | object Panel1: TPanel
1192 | Left = 0
1193 | Height = 226
1194 | Top = 0
1195 | Width = 1149
1196 | Align = alClient
1197 | BevelOuter = bvNone
1198 | ClientHeight = 226
1199 | ClientWidth = 1149
1200 | TabOrder = 0
1201 | object ListBox1: TListBox
1202 | Left = 0
1203 | Height = 226
1204 | Top = 0
1205 | Width = 1149
1206 | Align = alClient
1207 | ItemHeight = 0
1208 | TabOrder = 0
1209 | end
1210 | end
1211 | end
1212 | end
1213 | object TabFirebaseRealtimeDB: TTabSheet
1214 | Caption = 'Firebase Realtime DB'
1215 | ClientHeight = 562
1216 | ClientWidth = 1193
1217 | object GroupBox4: TGroupBox
1218 | Left = 20
1219 | Height = 324
1220 | Top = 10
1221 | Width = 1153
1222 | Align = alTop
1223 | BorderSpacing.Left = 20
1224 | BorderSpacing.Top = 10
1225 | BorderSpacing.Right = 20
1226 | BorderSpacing.InnerBorder = 5
1227 | Caption = ' Acessar e gerenciar dados do Firebase Realtime '
1228 | ClientHeight = 299
1229 | ClientWidth = 1149
1230 | TabOrder = 0
1231 | object layoutUserName24: TPanel
1232 | Left = 10
1233 | Height = 62
1234 | Top = 10
1235 | Width = 1129
1236 | Align = alTop
1237 | BorderSpacing.Around = 10
1238 | BevelOuter = bvNone
1239 | ClientHeight = 62
1240 | ClientWidth = 1129
1241 | TabOrder = 0
1242 | object lblLoginUsername5: TLabel
1243 | Left = 0
1244 | Height = 62
1245 | Top = 0
1246 | Width = 120
1247 | Align = alLeft
1248 | Alignment = taCenter
1249 | AutoSize = False
1250 | Caption = 'Endpoint'
1251 | Layout = tlCenter
1252 | ParentColor = False
1253 | end
1254 | object eRealtimeEndpoint: TEdit
1255 | Left = 135
1256 | Height = 32
1257 | Top = 15
1258 | Width = 979
1259 | Align = alClient
1260 | BorderSpacing.Around = 15
1261 | Font.CharSet = ANSI_CHARSET
1262 | Font.Height = -18
1263 | Font.Pitch = fpVariable
1264 | Font.Quality = fqDraft
1265 | ParentFont = False
1266 | TabOrder = 0
1267 | Text = 'etasks/v1'
1268 | TextHint = 'Endpoint da base de dados'
1269 | end
1270 | end
1271 | object layoutUserName25: TPanel
1272 | Left = 10
1273 | Height = 63
1274 | Top = 82
1275 | Width = 1129
1276 | Align = alTop
1277 | BorderSpacing.Around = 10
1278 | BevelOuter = bvNone
1279 | ClientHeight = 63
1280 | ClientWidth = 1129
1281 | TabOrder = 1
1282 | object lblLoginSenha14: TLabel
1283 | Left = 0
1284 | Height = 63
1285 | Top = 0
1286 | Width = 120
1287 | Align = alLeft
1288 | Alignment = taCenter
1289 | AutoSize = False
1290 | Caption = 'Coleção'
1291 | Layout = tlCenter
1292 | ParentColor = False
1293 | end
1294 | object eRealtimeCollection: TEdit
1295 | Left = 135
1296 | Height = 33
1297 | Top = 15
1298 | Width = 979
1299 | Align = alClient
1300 | BorderSpacing.Around = 15
1301 | Font.CharSet = ANSI_CHARSET
1302 | Font.Height = -18
1303 | Font.Pitch = fpVariable
1304 | Font.Quality = fqDraft
1305 | ParentFont = False
1306 | TabOrder = 0
1307 | Text = 'task-test'
1308 | TextHint = 'Coleção (tabela) do banco de dados'
1309 | end
1310 | end
1311 | object layoutUserName26: TPanel
1312 | Left = 10
1313 | Height = 63
1314 | Top = 228
1315 | Width = 1129
1316 | Align = alTop
1317 | BorderSpacing.Around = 10
1318 | BevelOuter = bvNone
1319 | ClientHeight = 63
1320 | ClientWidth = 1129
1321 | TabOrder = 2
1322 | object btnReadCollection: TButton
1323 | Left = 520
1324 | Height = 53
1325 | Top = 5
1326 | Width = 146
1327 | Align = alRight
1328 | BorderSpacing.Around = 5
1329 | Caption = '&Read Collection'
1330 | OnClick = btnReadCollectionClick
1331 | TabOrder = 0
1332 | end
1333 | object btnAddRecord: TButton
1334 | Left = 671
1335 | Height = 53
1336 | Top = 5
1337 | Width = 146
1338 | Align = alRight
1339 | BorderSpacing.Around = 5
1340 | Caption = '&Add Record'
1341 | OnClick = btnAddRecordClick
1342 | TabOrder = 1
1343 | end
1344 | object btnUpdateRecord: TButton
1345 | Left = 822
1346 | Height = 53
1347 | Top = 5
1348 | Width = 146
1349 | Align = alRight
1350 | BorderSpacing.Around = 5
1351 | Caption = '&Update Record'
1352 | OnClick = btnUpdateRecordClick
1353 | TabOrder = 2
1354 | end
1355 | object btnDeleteRecord: TButton
1356 | Left = 973
1357 | Height = 53
1358 | Top = 5
1359 | Width = 146
1360 | Align = alRight
1361 | BorderSpacing.Right = 5
1362 | BorderSpacing.Around = 5
1363 | Caption = '&Delete Record'
1364 | OnClick = btnDeleteRecordClick
1365 | TabOrder = 3
1366 | end
1367 | end
1368 | object layoutUserName27: TPanel
1369 | Left = 10
1370 | Height = 63
1371 | Top = 155
1372 | Width = 1129
1373 | Align = alTop
1374 | BorderSpacing.Around = 10
1375 | BevelOuter = bvNone
1376 | ClientHeight = 63
1377 | ClientWidth = 1129
1378 | TabOrder = 3
1379 | object lblLoginSenha15: TLabel
1380 | Left = 0
1381 | Height = 63
1382 | Top = 0
1383 | Width = 64
1384 | Align = alLeft
1385 | Alignment = taCenter
1386 | AutoSize = False
1387 | Caption = 'Task'
1388 | Layout = tlCenter
1389 | ParentColor = False
1390 | end
1391 | object eFieldTask: TEdit
1392 | Left = 79
1393 | Height = 33
1394 | Top = 15
1395 | Width = 321
1396 | Align = alLeft
1397 | BorderSpacing.Around = 15
1398 | Font.CharSet = ANSI_CHARSET
1399 | Font.Height = -18
1400 | Font.Pitch = fpVariable
1401 | Font.Quality = fqDraft
1402 | ParentFont = False
1403 | TabOrder = 0
1404 | TextHint = 'Write your task'
1405 | end
1406 | object lblLoginSenha16: TLabel
1407 | Left = 415
1408 | Height = 63
1409 | Top = 0
1410 | Width = 88
1411 | Align = alLeft
1412 | Alignment = taCenter
1413 | AutoSize = False
1414 | Caption = 'Category'
1415 | Layout = tlCenter
1416 | ParentColor = False
1417 | end
1418 | object eFieldCategory: TEdit
1419 | Left = 518
1420 | Height = 33
1421 | Top = 15
1422 | Width = 321
1423 | Align = alLeft
1424 | BorderSpacing.Around = 15
1425 | Font.CharSet = ANSI_CHARSET
1426 | Font.Height = -18
1427 | Font.Pitch = fpVariable
1428 | Font.Quality = fqDraft
1429 | ParentFont = False
1430 | TabOrder = 1
1431 | TextHint = 'Write a category to the task'
1432 | end
1433 | object chFieldDone: TCheckBox
1434 | Left = 854
1435 | Height = 63
1436 | Top = 0
1437 | Width = 275
1438 | Align = alClient
1439 | Caption = 'Done'
1440 | TabOrder = 2
1441 | end
1442 | end
1443 | end
1444 | object GroupBox5: TGroupBox
1445 | Left = 20
1446 | Height = 223
1447 | Top = 334
1448 | Width = 1153
1449 | Align = alClient
1450 | BorderSpacing.Left = 20
1451 | BorderSpacing.Right = 20
1452 | BorderSpacing.Bottom = 5
1453 | Caption = ' Dados do RealTimeDB'
1454 | ClientHeight = 198
1455 | ClientWidth = 1149
1456 | TabOrder = 1
1457 | object DataGrid: TStringGrid
1458 | Left = 0
1459 | Height = 198
1460 | Top = 0
1461 | Width = 1149
1462 | Align = alClient
1463 | ColCount = 4
1464 | Columns = <
1465 | item
1466 | ButtonStyle = cbsCheckboxColumn
1467 | Title.Caption = ''
1468 | ValueChecked = 'true'
1469 | ValueUnchecked = 'false'
1470 | end
1471 | item
1472 | Title.Caption = 'ID'
1473 | Width = 200
1474 | end
1475 | item
1476 | Title.Caption = 'Task'
1477 | Width = 550
1478 | end
1479 | item
1480 | Title.Caption = 'Category'
1481 | Width = 250
1482 | end>
1483 | FixedCols = 0
1484 | Flat = True
1485 | Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goColSizing, goRowSelect, goSmoothScroll]
1486 | RowCount = 1
1487 | TabOrder = 0
1488 | TitleStyle = tsNative
1489 | OnClick = DataGridClick
1490 | OnSelection = DataGridSelection
1491 | end
1492 | end
1493 | end
1494 | end
1495 | object GroupBox1: TGroupBox
1496 | Left = 15
1497 | Height = 146
1498 | Top = 625
1499 | Width = 1201
1500 | Align = alBottom
1501 | BorderSpacing.Around = 15
1502 | Caption = ' Log de Operações / Erros '
1503 | ClientHeight = 121
1504 | ClientWidth = 1197
1505 | TabOrder = 1
1506 | object MemoLog: TMemo
1507 | Left = 5
1508 | Height = 111
1509 | Top = 5
1510 | Width = 1187
1511 | Align = alClient
1512 | BorderSpacing.Around = 5
1513 | ReadOnly = True
1514 | ScrollBars = ssVertical
1515 | TabOrder = 0
1516 | end
1517 | end
1518 | object selectfile: TOpenDialog
1519 | Title = 'Selecione arquivo a enviar'
1520 | Left = 1096
1521 | Top = 680
1522 | end
1523 | end
1524 |
--------------------------------------------------------------------------------