lib/mangadex/auth.rb in mangadex-5.7.5.3 vs lib/mangadex/auth.rb in mangadex-5.8.0

- old
+ new

@@ -25,15 +25,23 @@ email: { accepts: String }, password: { accepts: String, required: true }, }), ) + if response.is_a?(Mangadex::Api::Response) && response.result == "error" + if block_given? + return yield(response) + else + return response + end + end + session_valid_until = Time.now + (15 * 60) session = response.dig('token', 'session') refresh = response.dig('token', 'refresh') - mangadex_user = Mangadex::Internal::Request.get('/user/me', headers: { Authorization: session }) + mangadex_user = Mangadex::Internal::Request.get('/user/me', headers: { Authorization: "Bearer #{session}" }) user = Mangadex::Api::User.new( mangadex_user_id: mangadex_user.data.id, session: session, refresh: refresh,