Skip to content

Commit 159e381

Browse files
committed
immich-go appears to retain/cache an API key
Fixes #211
1 parent 6634a2a commit 159e381

2 files changed

Lines changed: 20 additions & 20 deletions

File tree

cmd/shared.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,14 @@ func (app *SharedFlags) Start(ctx context.Context) error {
105105

106106
// If the client isn't yet initialized
107107
if app.Immich == nil {
108-
conf, err := configuration.Read(app.ConfigurationFile)
109-
confExist := err == nil
110-
if confExist && app.Server == "" && app.Key == "" && app.API == "" {
111-
app.Server = conf.ServerURL
112-
app.Key = conf.APIKey
113-
app.API = conf.APIURL
108+
if app.Server == "" && app.API == "" && app.Key == "" {
109+
conf, err := configuration.Read(app.ConfigurationFile)
110+
confExist := err == nil
111+
if confExist && app.Server == "" && app.Key == "" && app.API == "" {
112+
app.Server = conf.ServerURL
113+
app.Key = conf.APIKey
114+
app.API = conf.APIURL
115+
}
114116
}
115117

116118
switch {
@@ -125,10 +127,12 @@ func (app *SharedFlags) Start(ctx context.Context) error {
125127
}
126128

127129
// Connection details are saved into the configuration file
128-
conf.ServerURL = app.Server
129-
conf.APIKey = app.Key
130-
conf.APIURL = app.API
131-
err = conf.Write(app.ConfigurationFile)
130+
conf := configuration.Configuration{
131+
ServerURL: app.Server,
132+
APIKey: app.Key,
133+
APIURL: app.API,
134+
}
135+
err := conf.Write(app.ConfigurationFile)
132136
if err != nil {
133137
err = fmt.Errorf("can't write into the configuration file: %w", err)
134138
joinedErr = errors.Join(joinedErr, err)

docs/releases.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
# Release notes
22

3-
## Release 0.13.1
4-
5-
### Improvement: [#195](https://github.com/simulot/immich-go/issues/195) Rethink the user interactions with the CLI application #195
6-
7-
#### Use Bubble Tea library to provide a modern TUI (Terminal User Interface)
8-
9-
10-
### API KEY self provisioning
11-
When the server and the API keys aren't given on the command line, immich-go ask the user if he wants to get a key from a server, and saves it the configuration file.
3+
## Release 0.13.0
124

13-
### Fix [#199](https://github.com/simulot/immich-go/issues/199)
5+
### Fix [[#211](https://github.com/simulot/immich-go/issues/211)] immich-go appears to retain/cache an API key
6+
Fix the logic for retaining the credential:
147

8+
When given, the credentials are saved into the configuration file.
9+
When not given, the credential are read from the configuration file if possible.
10+
1511
## Release 0.13.0
1612

1713
### Improvement: [#189](https://github.com/simulot/immich-go/issues/189) Use a configuration file to store server's address and its API key

0 commit comments

Comments
 (0)