File tree Expand file tree Collapse file tree 4 files changed +10
-6
lines changed Expand file tree Collapse file tree 4 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 1
1
//! CDK common types and traits
2
- //!
3
2
pub mod amount;
4
3
pub mod dhke;
5
4
#[ cfg( feature = "mint" ) ]
Original file line number Diff line number Diff line change @@ -52,13 +52,13 @@ pub async fn cat_login(
52
52
let openid_discovery = mint_info
53
53
. nuts
54
54
. nutxx
55
- . expect ( "Nutxx definded " )
55
+ . expect ( "Nutxx defined " )
56
56
. openid_discovery ;
57
57
58
58
let oidc_client = OidcClient :: new ( openid_discovery) ;
59
59
60
60
let access_token = oidc_client
61
- . get_access_token (
61
+ . get_access_token_with_user_password (
62
62
sub_command_args. username . clone ( ) ,
63
63
sub_command_args. password . clone ( ) ,
64
64
)
Original file line number Diff line number Diff line change @@ -31,6 +31,9 @@ pub enum Error {
31
31
/// Unsupported Algo
32
32
#[ error( "Unsupported signing algo" ) ]
33
33
UnsupportedSigningAlgo ,
34
+ /// Access token not returned
35
+ #[ error( "Error getting access token" ) ]
36
+ AccessTokenMissing ,
34
37
}
35
38
36
39
impl From < Error > for cdk_common:: error:: Error {
@@ -183,7 +186,7 @@ impl OidcClient {
183
186
184
187
/// Get Access token (CAT)
185
188
#[ cfg( feature = "wallet" ) ]
186
- pub async fn get_access_token (
189
+ pub async fn get_access_token_with_user_password (
187
190
& self ,
188
191
username : String ,
189
192
password : String ,
@@ -206,7 +209,9 @@ impl OidcClient {
206
209
. json ( )
207
210
. await ?;
208
211
209
- let token = response. get ( "access_token" ) . expect ( "access token" ) ;
212
+ let token = response
213
+ . get ( "access_token" )
214
+ . ok_or ( Error :: AccessTokenMissing ) ?;
210
215
211
216
Ok ( token. to_string ( ) )
212
217
}
Original file line number Diff line number Diff line change @@ -162,8 +162,8 @@ impl Wallet {
162
162
/// use anyhow::Result;
163
163
/// use cdk::amount::{Amount, SplitTarget};
164
164
/// use cdk::cdk_database::WalletMemoryDatabase;
165
- /// use cdk::nuts::CurrencyUnit;
166
165
/// use cdk::nuts::nut00::ProofsMethods;
166
+ /// use cdk::nuts::CurrencyUnit;
167
167
/// use cdk::wallet::Wallet;
168
168
/// use rand::Rng;
169
169
///
You can’t perform that action at this time.
0 commit comments