-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c18abc0
commit cc4d45f
Showing
14 changed files
with
322 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package credentials | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
|
||
"github.com/google/uuid" | ||
htmx "github.com/zeiss/fiber-htmx" | ||
"github.com/zeiss/typhoon/internal/api/models" | ||
"github.com/zeiss/typhoon/internal/web/ports" | ||
) | ||
|
||
// IndexUserCredentialsControllerImpl ... | ||
type IndexUserCredentialsControllerImpl struct { | ||
ID uuid.UUID `json:"id" form:"id" param:"id" validate:"required:uuid"` | ||
|
||
ports.Users | ||
htmx.DefaultController | ||
} | ||
|
||
// NewIndexUserCredentialsController ... | ||
func NewIndexUserCredentialsController(db ports.Users) *IndexUserCredentialsControllerImpl { | ||
return &IndexUserCredentialsControllerImpl{ | ||
Users: db, | ||
DefaultController: htmx.DefaultController{}, | ||
} | ||
} | ||
|
||
// Error ... | ||
func (l *IndexUserCredentialsControllerImpl) Error(err error) error { | ||
fmt.Println(err) | ||
|
||
return nil | ||
} | ||
|
||
// Get ... | ||
func (l *IndexUserCredentialsControllerImpl) Get() error { | ||
err := l.BindParams(l) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
user := models.User{ID: l.ID} | ||
|
||
err = l.GetUser(l.Context(), &user) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
bb, err := user.Credentials() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
r := bytes.NewReader(bb) | ||
|
||
l.Ctx().Set("Content-Disposition", `attachment; filename="credentials.creds"`) | ||
return l.Ctx().SendStream(r) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.